Zend_Session_Namespace and setExpirationSeconds

4k Views Asked by At

I have problem for set a timeout on Zend_Auth Session this is my code :

$authSession = new Zend_Session_Namespace('Zend_Auth');
$authSession->setExpirationSeconds(60*60*24*1);

This code should make session expire after 1 day but actualy session expire after about 30 min. Anyone know what's wrong ? Thank you.

1

There are 1 best solutions below

1
On

The default session.gc_maxlifetime value in php.ini which specifies the number of seconds after which session data will be seen as 'garbage' is 24 minutes.

Calling Zend_Session_Namespace::setExpirationSeconds() is an internal to Zend Framework and has no effect on the session cookie itself or the session data on the server.

Make sure to adjust your session.gc_maxlifetime value accordingly such that PHP won't delete the data before you want it to. You can set this directly in php.ini or you can use ini_set somewhere in your bootstrap, or from your ZF application.ini file, use something like resources.session.gc_maxlifetime = 864000

See also:
Paragraph 2 of persisted login with Zend_Session::rememberMe
How do I create persistent sessions in PHP?
Paragraph 4 of Zend Framework Automatic Logout after inactivity