I have a question for a school project. How do I do an action when somebody's session gets ended. For instance, I want to delete a file that says a user is logged in when his session ends. If he closes the browser or if he doesn't do any request for a while?
2条回答 默认 最新
- dongsu3654 2013-02-01 20:21关注
You can do so by writing a custom session handler.
On this site you'll find a proper explanation:
http://phpmaster.com/writing-custom-session-handlers/
However, be aware that 'garbage collection' (cleaning up the file as you want to do) does NOT take place directly after the session was closed!
Php uses a setting 'session.gc_probability' that indicates that once every XXX requests, PHP will look for old/closed sessions and start to do garbage-collection
http://www.php.net/manual/en/session.configuration.php#ini.session.gc-probability
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 这个复选框什么作用?
- ¥15 单通道放大电路的工作原理
- ¥30 YOLO检测微调结果p为1
- ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
- ¥15 DS18B20内部ADC模数转换器
- ¥15 做个有关计算的小程序
- ¥15 MPI读取tif文件无法正常给各进程分配路径
- ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
- ¥15 setInterval 页面闪烁,怎么解决
- ¥15 如何让企业微信机器人实现消息汇总整合