proud Posted April 24, 2007 Share Posted April 24, 2007 I was asking whether there is a way to end a user's session in a site when he closes the browser? Any help will be appreciated indeed. Quote Link to comment https://forums.phpfreaks.com/topic/48518-how-to-end-a-session-when-the-browser-is-closed/ Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 if they close the page or go to another site you loss control but the session will expire Quote Link to comment https://forums.phpfreaks.com/topic/48518-how-to-end-a-session-when-the-browser-is-closed/#findComment-237363 Share on other sites More sharing options...
proud Posted April 24, 2007 Author Share Posted April 24, 2007 To describe the problem more furtherly I designed a chatroom, and when the user logs to the chatroom he is added in a users list using this command: if(session_is_registered("user_name")){ $chat_user=$user_name; session_register("chat_user"); $sql="INSERT INTO current_chatters VALUES('0','$chat_user')"; $result=mysql_query($sql); } Now when the user wants to logout he is supposed to click on an exit button which will direct him to page logout.php; In this page i can end his session and delete his name from table current_chatters : page logout.php: session_unregister("chat_user"); $query = "delete from current_chatters where chatter='$chat_user'"; $result = mysql_query($query); But imagine if he closes the browser? how can I delete his name from table current_chatters? Quote Link to comment https://forums.phpfreaks.com/topic/48518-how-to-end-a-session-when-the-browser-is-closed/#findComment-237419 Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 could have some javascipt or an iframe that refreshes that runs a "i'm still here script" Quote Link to comment https://forums.phpfreaks.com/topic/48518-how-to-end-a-session-when-the-browser-is-closed/#findComment-237422 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.