How to change session lifetime in PHP

Your session have so short life time at Your website?

Want to change their life time??

Check This Out...

There are many ways.. :

if You want to get unlimited session, set value to zero. default value of session.gc_maxlifetime is 1440. gc_maxlifetime value sets in second.

First way use .htaccess
[x] from .htaccess
Try this Code:

php_value session.gc_maxlifetime xxxxxx
php_value session.cookie_lifetime xxxxxx

Second Way used php.ini
[x] from php.ini

session.gc_maxlifetime = 0
// unlimited session.. You can used session invalidate to ended session lifetime.

Third way use source code php...
[x] from source code php
// to set session life time to one hour (3600 seconds)
ini_set(’session.gc_maxlifetime’, 60*60);


Related posts

Leave a Comment