Different users have asked questions regarding logging users out of the system for various reasons. Sometimes, it’s really necessary to know if a user has left your page or not.
Javascript can help you with this. Although it’s not a 100% optimal solution (maybe someone can comment on it), you might want to open a new window when your user leaves the first page. This new window should contain a PHP-page which logs the user out…
Here’s how you do it…
<html> <head> <script language = "javascript"> function Popup() { // open the popup window var popupURL = "PHP_Logoutpage_URL_HERE"; var popup = window.open(popupURL,"Popup",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,'); // delete the 'toolbar ... scrollbars stuff' if you want a normal //window if( navigator.appName.substring(0,8) == "Netscape" ) { popup.location = popupURL; } } </script> <body onUnload="Popup()"> Test </body> </html>
Hope this helps you. Always looking for any improvement…
Mail [email protected]