Jump to content

How to end a session when the browser is closed?


proud

Recommended Posts

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.