Zend Framwork Session on Internet Explorer [duplic

2019-08-16 05:29发布

问题:

This question already has an answer here:

  • Zend framework session lost 2 answers

Still couldn't make it works after post this link: Zend framework session lost

I have this Sign up form that allow users to register and redirect them right away to their pages. All work great on every browsers except INTERNET EXPLORER.

I have tried different ways, but still can't make it to work. After the user is saved to database the session won't store. But if I take out the save of the user, the session and cookies can be store.

Here's the code:

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;

Here's another way I'm doing but still doesn't working on 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:

Try using session_write_close before calling the redirect. Or I think Zend has an equivalent, see: Zend_Session::writeclose

Only other thing that comes to mind (with IE being the only browser giving you trouble) is P3P policy. Look at Talha's post here: Zend Sessions problem with IE8