0

One user should be loggedin to the application at a time. I am maintaining logs if user is logged in or logged out.On logged out (session destroy) i am updating a flag to false.If a flag is false another user can logged in into application. But if for any reason session expires Is there any way i can track it?

Moby M
  • 910
  • 2
  • 7
  • 26
Trushali
  • 76
  • 3
  • 1
    Quite frankly, this seems inane. What web-based application can only handle login of a single user at a time?! I can understand if a certain resource can only be edited by one at a time, for example. In that case you set a flag on the resource and let the flag expire after some time if it hasn't been updated, or whatever. But entire user login sessions…?! That just sounds like asking for user frustration in practice. – deceze Nov 14 '17 at 09:36
  • have a look also at this https://stackoverflow.com/questions/41165900/php-how-to-detect-if-a-session-has-expired-automatically – oetoni Nov 14 '17 at 09:40
  • I don't think there is a native way to do this. If I had to code it I'd use a "last_activity_at" value to handle a timeout for a logged in user. – Romain Ciaccafava Nov 14 '17 at 09:41

1 Answers1

-1

A good idea could be this: Use cookies. Every time user opens page, send him a unique cookie and save it on server. Next time, if user had that cookie, it would be acceptable. If other one log in, a cookie will be sent to him and value on server will be updated. So the old cookie won't be acceptable.

  • I think the idea is that other users *can't* login while one user is logged in. Not that new users would automatically supplant the old one. That seems even more inane and frustrating in practice. – deceze Nov 14 '17 at 10:14