Zend_Auth and RememberMe cookie sessions

Hold on Cowboy

This blog post is pretty old. Be careful with the information you find in here. It's likely dead, dying, or wildly inaccurate.

It’s bad enough that we make people pick a new username / password to access our site, but even worse is by default Zend_Auth sets a cookie that expires when the browser is closed.

Most sites have a “RememberMe” checkbox. This is handy so a user does not have to log into your site everytime.

To accomplish this, you simply add the following lines AFTER the users has been authenticated on your site. For me, this happens in my Auth_Adapter Class.

`

$session = new Zend_Session_Namespace('Zend_Auth');
// Set the time of user logged in
$session->setExpirationSeconds(24*3600);

Zend_Session::rememberMe();

`

It’s as simple as that.

References: http://en.2developers.net/post/authorization_using_zend_auth.html

Did this help you out? It took me a few days to piece together all this information together, I hope this saves you some time (who knows, maybe the future me will be thankful I wrote this down). Let me know your thoughts. shanestillwell@gmail.com