Home  >  Article  >  Backend Development  >  php设立session过期

php设立session过期

WBOY
WBOYOriginal
2016-06-13 12:05:01839browse

php设置session过期

ini_set('session.use_only_cookies', 1);?

ini_set('session.gc_maxlifetime', 600)

session_start()

setcookie(session_name(), session_id(), time() + 600);

?

session.use_only_cookies用于设置只允许使用cookie传值而不允许url传值

int_set需放置在session_start()上

setcookie放置在session_start()下面

?

session的过期时间并不是精准的,如100次请求,php删除一次session,即存在一定的概率。所以存在时间上的误差。

?

文章在独立博客地址:http://www.fsech.com/code/php/4.php

Statement:
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