Home > Backend Development > PHP Problem > How to set session timeout expiration time in php

How to set session timeout expiration time in php

王林
Release: 2023-03-02 16:46:02
Original
3760 people have browsed it

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")].

How to set session timeout expiration time in php

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)
Copy after login

Code implementation:

ini_set('session.gc_maxlifetime', "3600"); // 秒  
ini_set("session.cookie_lifetime","3600"); // 秒
Copy after login

You can also edit the php.ini configuration file and set session.gc_maxlifetime and session. cookie_lifetimeNode 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template