Internet Explorer上的Zend Framework会话

时间:2013-02-15 16:08:28

标签: php zend-framework session zend-db zend-session

发布此链接后仍无法使其正常工作: Zend framework session lost

我有这个注册表单,允许用户立即注册并重定向到他们的页面。除 INTERNET EXPLORER 外,所有浏览器都能很好地工作。

我尝试了不同的方法,但仍然无法使其发挥作用。 用户保存到数据库后,会话将不会存储。 但是,如果我取出用户的保存,会话和cookie就可以存储。

以下是代码:

public function signUpAction()
{
    $signupForm = new Application_Form_UserSignUp();
    if ($this->getRequest()->isPost())
    {

        if ($signupForm->isValid($this->getRequest()->getParams()))
        {
            $user = $this->_helper->model('Users')->createRow($signupForm->getValues());
            if ($user->save())
            {
                //Set email into cookies for displaying into login inputfield
                setcookie('display_email', $this->getRequest()->getParam('email'), time() + 3600*24*30, '/'); <-- not working
                Zend_Session::rememberMe(186400 * 14); <-- not working
                Zend_Auth::getInstance()->getStorage()->write($user); <-- not working

                $user->sendSignUpEmail(); <-- i'm receiving this email
                $this->getHelper('redirector')->gotoRoute(array(), 'invite');                   
                return;
            }
        }
    }
    $this->view->signupForm = $signupForm;

这是我正在做的另一种方式,但仍然无法使用 IE

public function signUpAction()
{

    $users = new Application_Model_DbTable_Users();
    $signupForm = new Application_Form_UserSignUp();
    if ($this->getRequest()->isPost())
    {
        $firstname = $this->getRequest()->getParam('first_name');
        $lastname = $this->getRequest()->getParam('last_name');
        $email = $this->getRequest()->getParam('email');

        if ($signupForm->isValid($this->getRequest()->getParams()))
        {
            $user = $this->_helper->model('Users')->createRow($signupForm->getValues());

            $user = array('email' => $email, 'first_name' => $firstname, 'last_name' => $last_name);
            $users->insert($user);
            Zend_Session::rememberMe(186400 * 14);
            Zend_Auth::getInstance()->getStorage()->write($user);
            $this->_redirect('invite');
        }
    }
    $this->view->signupForm = $signupForm;

1 个答案:

答案 0 :(得分:1)

在调用重定向之前尝试使用session_write_close。或者我认为Zend有一个等价物,参见:Zend_Session :: writeclose

只有其他想到的事情(IE是唯一给你麻烦的浏览器)是P3P政策。请看Talha的帖子:Zend Sessions problem with IE8