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. Quote Link to comment 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. Quote Link to comment 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.