rayden Posted July 8, 2009 Share Posted July 8, 2009 I'm trying to learn php and came across a problem. Here's the situation: I can log in and work on the same account from different browsers, or there are multiple instances of the same session. I've used simple sessions and session variables to verify the user. Ideally i'd like the old session to logout when i log in to the same account from another browser. Preventing the new browser to log in would also work. Any help would be appreciated. Link to comment https://forums.phpfreaks.com/topic/165249-preventing-multiple-instances-of-same-account/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 8, 2009 Share Posted July 8, 2009 You need to store the session id in the user table when the log in form is successful. Then you check on every page visit if the session id is the same or different. If it is different (someone using the first browser/old session id refreshes or visits a different page), you output a message that the account has been logged in at a different location and that they are logged out and must log in again. You can also prevent the 2nd browser from logging in by checking if the user table says the account is already logged in and there is a saved session id and it is not the same as the current visitor's session id. Simple login in systems that are not storing the logged in/looged out status and the session id in the user table and are not checking this information on each page visit cannot accomplish these type of advanced functional checks. Link to comment https://forums.phpfreaks.com/topic/165249-preventing-multiple-instances-of-same-account/#findComment-871514 Share on other sites More sharing options...
rayden Posted July 9, 2009 Author Share Posted July 9, 2009 Ok got it. Thanks for the help PFMaBiSmAd. Link to comment https://forums.phpfreaks.com/topic/165249-preventing-multiple-instances-of-same-account/#findComment-871827 Share on other sites More sharing options...
Q Posted July 9, 2009 Share Posted July 9, 2009 I see one problem with that solution. If the user leaves the site without logging out, they will be prevented from ever logging in again unless you make some timeout on your sessions id's .. Ideally you should use the first suggestion Link to comment https://forums.phpfreaks.com/topic/165249-preventing-multiple-instances-of-same-account/#findComment-871867 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.