PHP中的session的几个问题_PHP

WBOY
Release: 2016-06-01 12:31:25
Original
975 people have browsed it

session 的生命周期是多长
1 浏览器结束时其生命周期也同时结束,但是档案仍然存在于 /tmp/(sess_???)
2 下次重新开浏览器时会重新分配 sessionID,如果你使用 session_id() 把以前的 ID 带回来,则会去读取残存在 /tmp 处的 sess_???, 取回你之前所有已经设定的参数
3 可以在 php.ini 里修改 session 档案残存的时间

session.gc_maxlifetime = 1440 ; after this number of seconds, stored
data will be seen as 'garbage' and
cleaned up by the gc process

默认是 1440 秒,24分钟

使用 session 注意的存储路径问题

看看 php.ini 里对于 session 的设置

[Session]
session.save_handler = files ; handler used to store/retrieve data
session.save_path = /tmp ; argument passed to save_handler
in the case of files, this is the
path where data files are stored

默认是存于 /tmp 目录下,这个目录可不一定真有啊!!! 最好改为你的 php 安装路径,比如 c:/php

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