Destroy session when closing window

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
snicolas
Forum Commoner
Posts: 97
Joined: Tue Nov 09, 2004 8:32 am

Destroy session when closing window

Post by snicolas »

Is that possible without closing all windows?
Any help will be appreciated.
I just need to call my Logout(0 scripot when a user close the Explorer window.

s
snicolas
Forum Commoner
Posts: 97
Joined: Tue Nov 09, 2004 8:32 am

Post by snicolas »

anybody on this?
Archy
Forum Contributor
Posts: 129
Joined: Fri Jun 18, 2004 2:25 pm
Location: USA

Post by Archy »

Code: Select all

<?PHP
session_start();
// Next line is optional, it is not neccesary
session_unset();
session_destroy();
...
...
?>
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

In case any of the windows stays open you have a problem as there is no way to determine if the window is still open as this is on the client side.

However the approach to solve this is called garbage collection. You update a timestamp database file including ip and sessionid each time the user does a site call. If there was no site call in a defined timeframe the entry is invalid and a relogin has to be done no matter if any windows are still open or not.
Post Reply