Jump to content

One Login per User at any given time


StreamMe

Recommended Posts

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()

Link to comment
https://forums.phpfreaks.com/topic/82486-one-login-per-user-at-any-given-time/
Share on other sites

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. 

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.

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.