This article introduces to you a summary (recommended) of commonly used functions and global variables in PHP. It has certain reference value. Friends in need can refer to it. Hope it helps.
Method 1: Modify the configuration file php.ini, the default is 1440, 24 minutes, you can modify
php.ini About Session related settings (open php.ini file, in the "[Session]" section):
1, session.use_cookies: The default value is "1", which means that the SessionID is passed by Cookie, otherwise it is passed by Query_String;
2, session.name : This is the variable name stored in SessionID. It may be passed by Cookie or Query_String. The default value is "PHPSESSID";
3. session.cookie_lifetime: This represents the time that 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 Session cannot be used permanently!
4. session.gc_maxlifetime: This is the time that Session data is stored on the server side. If this time is exceeded, the Session data will be automatically deleted!
Method 2: Set in the program, use the ini_set() function to set the session expiration time, but when the script execution ends, the setting is cleared and the php.ini file will not be modified in the true sense
session_start(); ini_set('session.gc_maxlifetime',21600);
Recommended related articles:
What is the difference between the echo statement and the print statement in PHP5
How to combine php with ajax Processing pictures (code)
Related topic recommendations: php session (including pictures, texts, videos, cases)
The above is the detailed content of Introduction to two methods of modifying session survival time in PHP. For more information, please follow other related articles on the PHP Chinese website!