To set PHP survival time we can use the Session_set_cookie_params function or modify the php.ini file Oh, the following small part to introduce.
The first method: Session_set_cookie_params
function prototype void session_set_cookie_params (int $lifetime [, String $path [, String $domain [, bool $secure = False [, bool $htt Ponly = false]]])
| The code is as follows |
Copy Code |
$lifetime = 3600; One hours Session_set_cookie_params ($lifetime); Session_Start (); |
To set the lifetime of a Session manually:
| The code is as follows |
Copy Code |
Session_Start (); Save the day $lifeTime = 24 * 3600; Setcookie (Session_name (), session_id (), time () + $lifeTime, "/"); ? >
|
The second method:
If you have permission to operate the server, it is very, very simple to set up, just the following steps:
1, the "Session.use_cookies" set to 1, open the cookie storage SessionID, but the default is 1, generally do not change;
2, the "Session.cookie_lifetime" to the positive infinity (of course, no positive infinity parameters, but 999999999 and positive infinity is no difference);
3, the "Session.gc_maxlifetime" set to "Session.cookie_lifetime" the same time;
4. Modify the php.ini file session.gc.lifetime=10000
http://www.bkjia.com/PHPjc/632658.html www.bkjia.com true http://www.bkjia.com/PHPjc/632658.html techarticle to set PHP survival time we can use the Session_set_cookie_params function or modify the php.ini file Oh, the following small part to introduce. The first method: Session_set_cookie_params ...