Atozed Forums
Easy Way to identify closing a tab or browser - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: Easy Way to identify closing a tab or browser (/thread-2654.html)



Easy Way to identify closing a tab or browser - joelcc - 02-28-2022

If someone clicks the close button on a tab or browser, I need to invalidate a cookie.

Any ideas on how to do this?


RE: Easy Way to identify closing a tab or browser - kudzu - 02-28-2022

There is no reliable way to detect a tab or page being closed that I am aware of other than a timeout on the server side. And in that case, there is no way to kill the cookie any more. You can simply set your cookies to have rather short timeouts and just keep renewing them as the user uses your application. That way when they close, the cookie will disappear within an hour or even minutes depending on the lifetime you assign to the cookie.


RE: Easy Way to identify closing a tab or browser - Alexandre Machado - 03-02-2022

@Kudzu is correct. There is no way to accomplish that.

If you set your cookies to be a session cookie (in-memory cookie, transient cookie or non-persistent cookie. Do not confuse with "IW user session") it will be gone when the user closes the browser (the whole browser, not only the browser tab). It helps, although doesn't guarantee that the cookie will be destroyed.