PHP session is the default is 1440 seconds (24 minutes), if we want to let the session record does not expire what to do, next in our first to introduce the best way to not modify the program, because if you modify the program, the test department must be very depressed like me, then can only modify the system environment configuration, Actually very simple, open the php.ini setup file,
Modify line three as follows:
1, Session.use_cookies
Set this value to 1 and use a cookie to pass the SessionID
2, Session.cookie_lifetime
This represents sessionid the time that the client cookie is stored, the default is 0, which means that the browser shuts down SessionID. This is why the session of PHP cannot be used permanently! So let's set it to a number we think is big, 999999999 how, yes! That's it.
3, Session.gc_maxlifetime
This is the session data on the server side of the storage time, if more than this time, then the session data will be automatically deleted! Then we'll set it to 99999999.
If you cannot modify the php.ini file
The code is as follows |
Copy Code |
Session_Start (); Start session $_session[' count ']; Register Session variable Count Isset ($PHPSESSID)? session_id ($PHPSESSID): $PHPSESSID = session_id (); If $phpsessid is set, the SessionID is assigned to $PHPSESSID, otherwise it is generated SessionID
$_session[' count ']++; Variable count plus 1 Setcookie (' Phpsessid ', $PHPSESSID, Time () +3156000); Store SessionID into cookies Echo $count; Displays the value of the session variable count ?> |
http://www.bkjia.com/PHPjc/628957.html www.bkjia.com true http://www.bkjia.com/PHPjc/628957.html techarticle PHP session validity is 1440 seconds (24 minutes) By default, if we want to let the session record does not expire what to do, the next we introduce in the non-modification program is the best way, because such as ...