The default session validity period in PHP is 1440 seconds (24 minutes). What if we want the session to fail to expire? Let’s first introduce the best method without modifying the program, because if the program is modified , the testing department must be very depressed like me, then the only way to modify the system environment configuration is actually very simple, open the php.ini setting file,
modify the three lines as follows:
1. session.use_cookies
Set the value of this to 1 and use cookies to pass sessionid
2. session.cookie_lifetime
This represents the time that the SessionID is stored in the client cookie. The default is 0, which means that the SessionID will be invalidated as soon as the browser closes it... It is because of this that the PHP session cannot be used permanently! So let's set it to a number we think is big, how about 999999999, that's ok! that's all.
3. session.gc_maxlifetime
This is the time that the Session data is stored on the server side. If this time is exceeded, the Session data will be automatically deleted! Then we also set it to 99999999
If you cannot modify the php.ini file
The code is as follows
|
Copy code | ||||
$_SESSION['count']; // Register Session variable Count