Zend 2 Session - 双击“Enter”时销毁

时间:2014-02-07 17:48:46

标签: php session zend-framework zend-framework2

我遇到了Zend 2会话的问题

当我'快速'双击_POST表格中的'Enter'(在第一次回复之前两次提交表格)会话被销毁。当我以“正常速度”提交时,一切都还可以。

我的会话配置是此http://framework.zend.com/manual/2.1/en/modules/zend.session.manager.html

的精确副本

唯一的区别是

'session' => array(
    'config' => array(
        'class' => 'Zend\Session\Config\SessionConfig',
        'options' => array(
            'name' => 'myapp',
            'remember_me_seconds' => 3600, //60 min session
            'use_cookies' => true,
           // 'cookie_httponly' => true, -> not working with Zfc-user subdomain
            'cookie_domain'=>'domain.com',

        ),
    ),
    'storage' => 'Zend\Session\Storage\SessionArrayStorage',
    'validators' => array(
        'Zend\Session\Validator\RemoteAddr',
        'Zend\Session\Validator\HttpUserAgent',
    ),
),

在控制器中我有:

const NAMESPACE_REGORG = 'initialized';

protected $_sessionRegContainer;

public function packageAction() {

    //check if user login and redirect
    if ($this->zfcUserAuthentication()->hasIdentity()) {
       //some staff here
    }

    //save value to session
    $package = $this->getEvent()->getRouteMatch()->getParam('id');
    $this->_sessionRegContainer = new Container(static::NAMESPACE_REGORG);
    $this->_sessionRegContainer->package = $package;
    return $this->redirect()->toRoute(static::ROUTE_LOGIN);
}

public function loginAction() {

    //restore session
    $this->_sessionRegContainer = new Container(static::NAMESPACE_REGORG);

    //create form staff.. if submited by double click session is loosing
    //value of $this->_sessionRegContainer->package
}

页面使用Doctrine 2 ORM,用于身份验证的Zfc用户模块和所有Zend 2相关内容的子域 - main domain.com是静态html。

值得一提的是,当我使用简单的新Container()会话而没有来自Zend页面的所有设置时 - 会话工作正常“双击”但是zfc-user停止工作:(

知道会话被销毁的原因吗?任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

我通过删除

对其进行了排序
$session->start();
$session->rememberMe();
来自Zend 2 exmple setup的

- > http://framework.zend.com/manual/2.1/en/modules/zend.session.manager.html

双击会话销毁结束(已修复)。 PS。看起来他们已经从exmple中删除了rememberMe()。 谢谢大家的帮助!