StreamMe Posted December 20, 2007 Share Posted December 20, 2007 I googled this, but to my surprise didnt find anything cept a lead. On some site it said if I set the username as the session key, that any other user using that key would get the boot. Am I setting session keys wrong(i cant find help on this either). Either way - end goal is to have only 1 user logged in at any given time per user name, in the easiest manner possible. session_id(md5($RP08)); - before session_start() Quote Link to comment https://forums.phpfreaks.com/topic/82486-one-login-per-user-at-any-given-time/ Share on other sites More sharing options...
adam291086 Posted December 20, 2007 Share Posted December 20, 2007 Well what you could do is this. Add a feild to a database called logged in. Then when a user logs in get the code to check username, password and the logged in status. If the logged in feild ==Yes then error "someone is already logged in" if logged in feild =="no" then header location = index.php. Then when a user logs out get it to change the logged in status to ==no. This is very reliant on users logging in and out though. If a user doesn't log out then the system will fail. One way around that would be to have session time outs that log you out It is a very simple way of doing what you want. One of the more skilled people may know a better way. Quote Link to comment https://forums.phpfreaks.com/topic/82486-one-login-per-user-at-any-given-time/#findComment-419306 Share on other sites More sharing options...
beansandsausages Posted December 20, 2007 Share Posted December 20, 2007 try sumit like this <?php $value = 'logged_in'; setcookie("TestCookie", $value); setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */ update `db` set logged _in=`no` ?> know that wont work but just a idea set the ciikie to destroy a hour from now or when ever. Quote Link to comment https://forums.phpfreaks.com/topic/82486-one-login-per-user-at-any-given-time/#findComment-419322 Share on other sites More sharing options...
cooldude832 Posted December 20, 2007 Share Posted December 20, 2007 I'm going to go against everything I said about reading individual session, and say if you can find a session with that UserID you know they are logged in Quote Link to comment https://forums.phpfreaks.com/topic/82486-one-login-per-user-at-any-given-time/#findComment-419472 Share on other sites More sharing options...
StreamMe Posted December 20, 2007 Author Share Posted December 20, 2007 Could this be done with Session Keys? If so, how? Quote Link to comment https://forums.phpfreaks.com/topic/82486-one-login-per-user-at-any-given-time/#findComment-419586 Share on other sites More sharing options...
Pancake Posted December 20, 2007 Share Posted December 20, 2007 This would probably require the use of a database to be completely exact. This *might* help... http://www.phpit.net/article/creating-whosonline-script-php/ Quote Link to comment https://forums.phpfreaks.com/topic/82486-one-login-per-user-at-any-given-time/#findComment-419588 Share on other sites More sharing options...
cooldude832 Posted December 20, 2007 Share Posted December 20, 2007 Could this be done with Session Keys? If so, how? you can't rewrite the session keys, the only way I can think of doing it, and its a weak one is a method similar to users online, but like I said its still very weak. Quote Link to comment https://forums.phpfreaks.com/topic/82486-one-login-per-user-at-any-given-time/#findComment-419591 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.