Re: [PHP] how to kill a session by closing window or tab clicking on X?



On Mon, 2008-10-27 at 09:56 -0500, Afan Pasalic wrote:
Stut wrote:
On 27 Oct 2008, at 14:10, Afan Pasalic wrote:
I'm sorry for posting this more javascript then php question, but
it's somehow php related.
here is the issue: very often people close the window/tab without
logging out. I need solution how to "recognize" when [x] is clicked
(or File >> Close) and kill the session before the window/tab is closed.

few years ago, before firefox and tabs, I solved this by javascript
and onClose() as a part of body tag. now, it doesn't work anymore.

any suggestion/opinion/experience?

That event should still fire regardless of whether it's a window, tab
or iframe. It refers to the page closing, not the window. However, any
event that fires when the user leaves a page (either by clicking on a
link or closing the window) is likely to be prevented by popup
blockers, so you can't rely on it working at all.

A sensible session timeout is the only real solution to this "issue",
possibly aided by a periodic keepalive request.

-Stut


as you said, I was asked by pop-up blocker to allow this "event". I can
use it - in case there is no popup blocker but in general, as you said,
can't rely on this.

session timeout will do the jobe. not exactly the way I want but...

thanks.

afan

You could set the timeout to a low value, and have the browser make AJAX
requests at an interval less than this. If you don't get your session
update request from the browser, you can deem it as crashed or closed.


Ash
www.ashleysheridan.co.uk

.



Relevant Pages

  • RE: How to create a local server (i.e., localhost)
    ... logon user session and hard to automate in a non-interactive service ... Since the webserver.exe is a winform application which has a main window, ... already running on a given port? ...
    (microsoft.public.dotnet.languages.vb)
  • RE: automatic logoff - two scenarios
    ... in order to prevent losing established remote desktop connections or e-mail ... continue the session with a pop-up Yes/No window. ... If the user does not respond after one minute, the pop-up window will ...
    (microsoft.public.windows.server.sbs)
  • Re: cookie not sent with window.open
    ... through the web-server then the browser would not pass the session cookie to ... >> - the user clicks this hyperlink, which opens a new Internet Explorer ... >> open a new window calling useCookie.asp ...
    (microsoft.public.inetserver.asp.general)
  • Re: Concurrent session issues. Currently our website can have only one window open. Help me solve th
    ... Maybe I'm abusing the use of $_SESSION but I have data entry processes ... way I know that this would be possible (uses arrays in arrays). ... I were to open up a window and start the data entry it would overwrite ... each 'step1', then no matter how many windows they have open, each one ...
    (comp.lang.php)
  • Possible IE 6 Bug - Differences Between Windows Explorer And IE
    ... It records information in the Session ... if I enter the URL into the address bar of a Windows Explorer ... window (E.g. double click on 'My Computer' and use the window that ... I believe this is due to session cookies ...
    (microsoft.public.internet.explorer.ieak)