Home > Article > Backend Development > How to set session timeout expiration time in php
The method for php to set the session timeout expiration time is: it can be achieved through the ini_set() function. This function is used to set the value of php.ini, which takes effect when the function is executed. The specific code is: [ini_set('session.gc_maxlifetime', "3600")].
To set the session timeout expiration time, you can use the ini_set() function.
(Recommended tutorial: php tutorial)
Function introduction:
PHP ini_set is used to set the value of php.ini when the function is executed It takes effect. After the script ends, the setting becomes invalid. You can modify the configuration without opening the php.ini file, which is very convenient for virtual spaces.
Syntax:
string ini_set(string $varname, string $newvalue)
Code implementation:
ini_set('session.gc_maxlifetime', "3600"); // 秒 ini_set("session.cookie_lifetime","3600"); // 秒
You can also edit the php.ini configuration file and set session.gc_maxlifetime
and session. cookie_lifetime
Node attribute value, so you can also set the timeout expiration time.
Related topic recommendations: php session (including pictures, texts, videos, cases)
The above is the detailed content of How to set session timeout expiration time in php. For more information, please follow other related articles on the PHP Chinese website!