如何在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.
我正在开发php项目。 所有我想这样做,当我关闭浏览器以便取消设置或破坏会话时。 p>
这里我也尝试了 p>
ini_set('session。 session_start()之前的cookie_lifetime',0)和session_set_cookie_params(0); p>
它在Windows操作系统中正常工作但在MAC操作系统中没有。 p>
谢谢 提前。 p> div>
There are two parts to a session.
- The data stored on the server
- 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.
it's working fine in Windows
That more or less means it works.
but not work in MAC os
This is probably a misunderstanding. You need to close all browser windows for the browser to destroy session cookies. Most likely you've only closed one of multiple windows, and at least one browser instance still exists (you can check that kind of thing with top
in a terminal window).