Page 1 of 1

Allow only one user login

Posted: Thu Oct 17, 2002 3:25 pm
by redptam
Hello,

I am trying to figure out how to allow only one user at a time to login to say a database. I want to prevent update issues such as user 2 overwriting user 1's data. I want to do this with sessions can anyone help?

-Philippe-

Posted: Thu Oct 17, 2002 3:32 pm
by mr_griff
There are several ways to implement as setup like this. One way would be to have a database table that you can use as a flag, marking that someone is logged in already. You will probably want to have a field that you can update with the last time the logged in user made a change or visited a page. That way if the user forgets to log out, you do have to manually go into the database and reset the flag so someone else can login. For example if it has been 20 minutes since the logged in user has accessed a page log them out and reset the flag.

Posted: Thu Oct 17, 2002 7:43 pm
by volka
and if you want to do it at the database layer tkae a look at http://www.mysql.com/...MySQL_Optimisation.html#Locking_Issues

Posted: Fri Oct 18, 2002 12:10 am
by redptam
Thank you both for replying to my post.

I had thought of using a flag in the database with a timestamp of user's
last page access. However, I was concerned with the logout problem of when the user closes the browser window instead of clicking logout. I was hoping much of this problem would be handled by session expire times.
I must say that I had not thought of table locking at all. However, since I am new to PHP and currently learning about databases in my Database Systems class, I think that table locking is a bit beyond my skillset. I do much appreciate your suggestions though and I may try this in the future!
Is there no way to set a session flag variable that can be seen by all browsers and different users on different computers to check if a user is currently into the database?