How to modify the SESSION validity time in PHP?

Guanhui
Release: 2023-03-03 08:16:01
Original
3034 people have browsed it

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, "/"); ?>
Copy after login

2. Set by using the "session_set_cookie_params" function;

<?php // 保存一天 $lifeTime = 24 * 3600; session_set_cookie_params($lifeTime); session_start(); $_SESSION["admin"] = true; ?>
Copy after login

3 , set in "session_start()".

 60 * 60 ]);
Copy after login

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!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!