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 one day $lifeTime = 24 * 3600; Setcookie (Session_name (), session_id (), time () + $lifeTime, "/"); ? >
|
The second method:
If you have the right to operate the server, setting this is very, very simple, just the following steps are required:
1, the "Session.use_cookies" set to 1, open the cookie store SessionID, but the default is 1, generally do not have to modify;
2, the "session.cookie_lifetime" Change to positive infinity (of course, there is no positive infinite parameters, but 999999999 and positive infinity is no difference);
3, the "Session.gc_maxlifetime" set to and "Session.cookie_lifetime" the same time;
4, modify php.ini file session.gc.lifetime=10000