Home >Backend Development >PHP Problem >How to modify the SESSION validity time in PHP?
How to modify the SESSION validity time in PHP?
1. Set the valid time of SESSION by using the function "setcookie()";
<?php session_start(); // 保存一天 $lifeTime = 24 * 3600; setcookie(session_name(), session_id(), time() + $lifeTime, "/"); ?>
2. Set by using the "session_set_cookie_params" function;
<?php // 保存一天 $lifeTime = 24 * 3600; session_set_cookie_params($lifeTime); session_start(); $_SESSION["admin"] = true; ?>
3 , set in "session_start()".
<?php session_start([ 'cookie_lifetime' => 60 * 60 ]);
Recommended tutorial: "PHP"
Related topic recommendations: php session (including pictures and text , videos, cases)
The above is the detailed content of How to modify the SESSION validity time in PHP?. For more information, please follow other related articles on the PHP Chinese website!