How can i do so only 1 can be online for the 1 user at the time? Idea ?
So you e.g can not login to User1 on one pc/browser and then on the other pc/browser login to User1?
I have my communitysystem in PHP, and it stores in sessions..
The session is unique to whomever has that session ID, which is determined by the cookie. Yes, it's unique to each user. Variable scope means nothing here. Each request handled by PHP is isolated and has its own global scope (unless you have built your own daemon or something).
PHP sessions are (by default) file based, so you can have as many of them as can fit on your server's disk. Save this answer. Show activity on this post. No, this exactly means that there can't be more than 30 simultaneous connections.
You could store the session ID (and last access time) in a database, and reject login attempts for users with different session IDs if the last-access time is too recent(say, within the past 20 minutes). Clear the ID on logout, of course.
Note, though, if a user closes their browser without logging out and then reopens it, they may well be locked out for a while (the 20 minutes above, or whatever interval you decide on), since they won't have the matching session cookie anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With