Home > php教程 > php手册 > PHP中设置Session过期方法

PHP中设置Session过期方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:09:11
Original
1016 people have browsed it

Session的有效期是随浏览器进程的,浏览器关掉后就没了,那么怎么像Cookies那样设置过期时间呢?下面这段代码就可以实现。 12345 ?php$cookies_life_time = 24 * 3600; //过期时间,单位为秒,这里的设置即为一天session_start();setcookie(session_name() ,

Session的有效期是随浏览器进程的,浏览器关掉后就没了,那么怎么像Cookies那样设置过期时间呢?下面这段代码就可以实现。

 

1
2
3
4
5
Copy after login
<?php $cookies_life_time = 24 * 3600;   //过期时间,单位为秒,这里的设置即为一天
session_start();
setcookie(session_name() ,session_id(), time() + $cookies_life_time, "/");
?>
Copy after login
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 Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template