zohab Posted October 6, 2009 Share Posted October 6, 2009 Hi, In my site, When user login then I set username,uniqueid in session and create new entry in active users section. When user logout then i destory session and delete entry in active_users section. example A.user1 login then 1.$_SESSION['user1name'];$_SESSION['uniqueid']; 2.insert into active_users (uniqueid,username) values('1','user1name'); B.user1 logout 1.session_destory(); 2.delete from active_users where username='user1name' and uniqueid='1'; When user click on logout link then he will be logout and operation B is perform. when user close browser then session_destroy() but active_user table entry does not update because i do not know that user close the browser. How can I delete entry from active users table when user close browser. Link to comment https://forums.phpfreaks.com/topic/176677-delete-query-and-destroy-session-when-browser-close/ Share on other sites More sharing options...
cags Posted October 6, 2009 Share Posted October 6, 2009 As PHP is not a syncronous technology, that is to say there is not a permanent flow of data between the client and the server, you will probably need to track the time period since the user last accessed a page and logout after a period of time. So your active_users table will have a field for last_access, whenever a visitor views a page that displays a list of active_users you would compare the current time to the last_access time for all active users and remove any that have been longer than your timeout period before displaying the list. Link to comment https://forums.phpfreaks.com/topic/176677-delete-query-and-destroy-session-when-browser-close/#findComment-931447 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.