Modify the three rows as follows:
1. session. use_cookies
Set this value to 1 and use cookie to pass sessionid
2. session. cookie_lifetime
This indicates the time when SessionID is stored in the client Cookie. The default value is 0, indicating that the session id will be voided once the browser closes it ...... This is why PHP sessions cannot be used permanently! So let's set it to a number that we think is big. How about 999999999? Yes! That's it.
3. session. gc_maxlifetime
This is the time when Session data is stored on the server. If this time is exceeded, Session data will be automatically deleted! Then we set it to 99999999.
If you cannot modify the php. Ini file
The code is as follows: |
Copy code |
<? Php Session_start (); // start the Session $ _ SESSION ['count']; // registers the Session variable count. Isset ($ PHPSESSID )? Session_id ($ PHPSESSID): $ PHPSESSID = session_id (); // If $ PHPSESSID is set, the SessionID is assigned to $ PHPSESSID. Otherwise, the SessionID is generated. $ _ SESSION ['count'] ++; // variable count Plus 1 Setcookie ('phpsessid ', $ PHPSESSID, time () + 3156000); // store the SessionID to the Cookie Echo $ count; // display the value of the Session variable count ?> |