dongnao1908 2013-05-27 15:02
浏览 49
已采纳

ZF2:身份验证会话出现问题

I have a strange problem with the session after an authentication.

The whole authentification part works, troubles come after that :

        $result = $this->getAuthService()->authenticate();

            if ($result->isValid()) {
                $storage = $this->getAuthService()->getStorage();
                $storage->write(($this->getAuthService()
                        ->getAdapter()
                        ->getResultRowObject(array(
                                'email_utilisateur',
                                'password_utilisateur',
                            ))));
                $redirect = 'success';                    
            }

Right now, I am logged, and email+password are stored, in the "Zend_Auth" key (don't pay attention to the fact that I store password btw, it's for the example ^^).

But when I go on another page (even if it's the same), my Session key "Zend_auth" gets broken, and I have an incomplete PHP object....

Array
(
     [__ZF] => Array
         (
             [_REQUEST_ACCESS_TIME] => 1369667659.7526
         )

     [Zend_Auth] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => Zend\Stdlib\ArrayObject
        )

)

So, any idea why changing page would screw my session variable ?

Thanks in advance, I've spent like 5 hours on this problem, testing things etc...

EDIT 28/05/2013 :

So, I still didn't find. Anyway, the object that gets corrupted is a Zend\Stdlib\ArrayObject. A reason why this arrayobject gets corrupted would be that the session starts before the inclusion avec Zend\Stdlib\ArrayObject. I'll try to figure it out, but if that's the reason, then it's a bug of the framework. By the way, I'm using ZF 2.2.

  • 写回答

1条回答 默认 最新

  • doujingke4981 2013-05-28 08:24
    关注

    I FOUND ! So, as said, the reason was that the session started before the ArrayObject thing was known by the application. And, as you can read there :

    https://zf2-docs.readthedocs.org/en/latest/modules/zend.session.advanced-usage.html

    **Do not enable PHP‘s session.auto_start setting. If you do not have the ability to disable this.**
    

    And that was the thing. session.auto_start was enabled in my php.ini. In order to fix this, you must set it to 0 in your php.ini file :

    php_value session.auto_start 0
    

    If your PHP is used for several applications/sites, then add this line to your .htaccess instead :

    php_value session.auto_start 0
    

    This will override the actual value of the php.ini

    Hope it will help someone ^^.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号