首先你需要知道“过了20多分钟以后SESSION就失效了”的原因 在php.ini中有session.gc_maxlifetime=1440,这个1440是秒也就是24分钟。 相关的说明为 ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process. ; WARNING: Your filesystem must store access times. Windows FAT does ; not. So, see session_set_save_handler() and write your own ; session handler with a different mechanism for cleaning up sessions. 意思是当session临时文件在最后修改的session.gc_maxlifetime之后可由系统的“清洁工”(gc)删除 当然session临时文件删除了,自然也就“失效”了 另外有 ; Define the probability that the 'garbage collection' process is started ; on every session initialization. ; The probability is calculated by using gc_probability/gc_dividend, ; e.g. 1/100 means 1%.session.gc_probability=1 session.gc_dividend=100 通知gc进程每次删除可删除文件的session.gc_probability/session.gc_dividend知道了这些,就可以采取措施了 你可以令session.gc_probability=0,不过这样以来就得完全依靠自己来清除垃圾了 你可以令session.gc_maxlifetime=一个较大的数字比如86400。总不能整天都在维护吧 你可以指定自己的session处理函数,而炒gc的“鱿鱼”
或用session_set_cookie_params (0);进行设置。
如果关闭窗口时取消Session,设置Session的值为空就行了
我的就是这样设置的啊,怎么还会有时间限制哪?
在php.ini中有session.gc_maxlifetime=1440,这个1440是秒也就是24分钟。
相关的说明为
; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
; WARNING: Your filesystem must store access times. Windows FAT does
; not. So, see session_set_save_handler() and write your own
; session handler with a different mechanism for cleaning up sessions.
意思是当session临时文件在最后修改的session.gc_maxlifetime之后可由系统的“清洁工”(gc)删除
当然session临时文件删除了,自然也就“失效”了
另外有
; Define the probability that the 'garbage collection' process is started
; on every session initialization.
; The probability is calculated by using gc_probability/gc_dividend,
; e.g. 1/100 means 1%.session.gc_probability=1
session.gc_dividend=100
通知gc进程每次删除可删除文件的session.gc_probability/session.gc_dividend知道了这些,就可以采取措施了
你可以令session.gc_probability=0,不过这样以来就得完全依靠自己来清除垃圾了
你可以令session.gc_maxlifetime=一个较大的数字比如86400。总不能整天都在维护吧
你可以指定自己的session处理函数,而炒gc的“鱿鱼”