ZF2-52: ::regenerateId() fails and ::rememberMe() clears session storage
Description
When using {{Zend\Authentication\Storage\Session}} there is no easy way to use {{SessionManager::rememberMe()}} due to a bug.
When creating new session cookie, SessionManager clears the whole session registry which also clears Authentication storage.
i.e.
$sessionManager->start();
$auth = new AuthService(new AuthSession('Zend_Auth','storage',$sessionManager));
// (...) perform authentication
$auth->getStorage()->write($user->id);
$sessionManager->rememberMe(84600); // this clears the authentication storage because of a bug.
Comments
Posted by Artur Bodera (joust) on 2011-08-22T09:50:43.000+0000
Current session implentation performs the following tasks when regenerating id (using php session extension, assuming session started before): 1) session_start() 2) session_destroy() 3) session_regenerate_id() 4) session_start()
This will fail with PHP 5.0+, because of how session extension works. Here is a test code:
Note there are NO COOKIES being sent. This is because session_destroy() will prevent any consequent operations and will refuse to send proper cookies.
Here is a proper way to regenerate session id:
Alternatively, the regeneration has to occur BEFORE session_destroy(). This is a PHP quirk, mentioned here: http://php.net/manual/en/…
~Tested with PHP 5.3.6 and 5.2.9~
Posted by Artur Bodera (joust) on 2011-08-22T10:38:30.000+0000
Pull request: https://github.com/zendframework/zf2/pull/352
Posted by Artur Bodera (joust) on 2011-08-25T12:15:04.000+0000
Please pull