How to make user session go on for 24 hours? How to make user session go on for 24 hours? apache apache

How to make user session go on for 24 hours?


In php.ini, set:

; 24 hour session cookiesession.cookie_lifetime = 86400; Prevent server from cleaning up session; Some value higher than the cookie lifetimesession.gc_maxlifetime = 200000 


Strange. Sessions should stay for quite a long time.Try checking your code for any accidental session_destroy()s.

If that doesn't work, then maybe try using cookies:

setcookie(name, value, expire); 

So, to set a cookie variable in PHP, you would simple use

<?php    setcookie("MyCookie", "MyValue", time()+60*60*24); ?>

The expire value is in seconds. Using the code above, you would be able to set a cookie called "MyCookie" with the value "MyValue" and lasts for 24 hours.

To retrieve the value of this cookie, you could use

<?php    print($_COOKIE['MyValue']);?>

Note that cookies MUST be set before the tag is called.

If cookies don't work either, then it's probably a problem with your php.iniCan you post your php.ini if cookies don't work?

Hope this helps!