Zend_Session does not allow you to destroy and recreate a session

My requirement: when the user agent change session should be destroyed and it should start a new session. But Zend_Session :: start () throws an exception if destroy was called before start ().


try { 
    Zend_Session::start();   
} catch (Zend_Session_Exception $e) {   
    Zend_Session::destroy(true);
    Zend_Session::start(); // breaking here   
    Zend_Session::regenerateId();   
}  

Zend_Session::registerValidator(new Zend_Session_Validator_HttpUserAgent());

An exception:

Throw a "Zend_Session_Exception" exception with the message "Session was explicitly destroyed during this request, attempt to restart is not allowed." in the library \ Zend \ Session.php: 431

EDIT:
The reason is that the second start () command is silently ignored if it was already called in this request. I posted a question, I hope they accept it.


if (self::$_sessionStarted) {
    return; // already started
}

Please vote for him
http://framework.zend.com/issues/browse/ZF-11420

+3
2

, .

try {
        Zend_Session::start();
    } catch (Zend_Session_Exception $e) {
        Zend_Session::destroy(true);

        $this->bootstrap('frontController');
        $front = $this->getResource('frontController');
        $front->setRequest(new Zend_Controller_Request_Http()); 
        $front->setResponse(new Zend_Controller_Response_Http());

        $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
        $redirector->gotoUrl($front->getRequest()->getRequestUri(),array('prependBase' => false));

    }
+2

? destroy()

EDIT:

Zend_Session , php-, , , php , Zend Framework.

:

if (self::$_sessionStarted && self::$_destroyed) {
    require_once 'Zend/Session/Exception.php';
    throw new Zend_Session_Exception('The session was explicitly destroyed during this request, attempting to re-start is not allowed.');
}

Zend_Session , , , .

+1

All Articles