Forum Moderators: coopster
Which solution do you recommend to limit the number of simultaneous logins by each user?
Thanks in Advance,
So what are best practices? Storing number of sessions of each user in database (say, table ONLINES), or searching the session text files on the server (if it helps at all), or any other similar practice...
when someone logs on, I generate a cookie that looks like
"user-name+35533266367"
where 35533266367 is a completely random number each time. That's saved in the user record, overwriting any previous logon cookie
That has several advantages both the user and me:
That's with cookies. Sesssion-ids can work the same way.
You can have an extra field that stores the session's active state. That way, if the session IS active, you can tell them they need to log out before they can log back in.
Just be careful when you implement it, so that you don't prevent them from opening an additional instance of their current browser (unless that's what you're intention is).
The effect is that the last instance to login wins.
The problem with the cookie-only method is in the case where a users uses a second computer to make the login attempt.
The method I described does not have that problem. As John_k says, by having a unique cookie [or user session id] for each logon, the "last instance to login wins."
I avoid having a separate logon table as the cookie [or etc] contains the userid. That may be considered a security exposure on some systems, but (as the HTML will usually contain the userid somewhere), it's not one that bothers me for the applications I support.
That's why it's recommended to store the information on the server.
Maybe I wasn't clear. The logon validation information is held on the server. The process is: