drgaeqdqiiyg14608 2012-05-09 10:34
浏览 34
已采纳

如何在mac os中关闭浏览器时销毁会话?

I am working on php project. All I want to do that, when I close the browser so unset or destroy the session.

Here I also tried

ini_set('session.cookie_lifetime', 0) and session_set_cookie_params(0) before session_start();

It's working fine in Windows os but not in MAC os.

Thanks in Advance.

  • 写回答

2条回答 默认 最新

  • dpnvrt3119 2012-05-09 10:40
    关注

    There are two parts to a session.

    1. The data stored on the server
    2. The cookie with the session id on the client

    There is no reliable way to delete the data on the server when the browser is closed. Every sane session system just cleans up old data periodically (if there has been no sign of the associated browser for N minutes).

    The cookie on the browser is usually sent without an expiry time, which means it will expire when the browser exits. This works reliably.

    If whatever you have is doing what you want on Windows clients, then I would assume that you are talking about expiring the cookie.

    This will happen on Mac as well as Windows. My best guess is that there is a problem with your testing. On Windows, applications generally exit when the last window is closed. On Mac, applications generally require that you explicitly quit them but remain open if you just close the last window.

    To make sure the cookie expires you must expressly exit the browser (by picking Quit from the menu or right clicking and picking exit on the icon in the Dock).

    There is no way for the server to detect when the last window has been closed and kill the session remotely.

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

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?