Question

I was reading through this tutorial, and at one point in the code, the user info is retrieved from the database and a session is created for the user:

// the default storage is a session with namespace Zend_Auth  
$authStorage = $auth->getStorage();  
$authStorage->write($userInfo);

I tried this, but this session expires once the browser is closed. So my question is how do I combine this with Zend_Session to create a cookie that lasts for 20 days or something? I can't figure it out through the Zend_Session documentation..

Any help is appreciated! Thanks

Was it helpful?

Solution

Don't mix 2 different tasks. One task you have is "authentication", another is "remember me feature".

So don't try to solve them in one shot.

For remember me store another cookie with some random hash and keep a table that assotiates each random hash with particular user_id.

Also, it is a lot of discussions about "remember me" implementations here at SO: http://www.google.ru/search?q=site%3Astackoverflow.com+remember+me&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ru:official&client=firefox

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top