duandai7601 2013-02-01 20:09
浏览 90
已采纳

会话在php结束时如何做某事

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?