Jump to content

PHP: Log Out Users

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Ronin

Ronin

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 309 posts
I use sessions to log in users. When the user logs in I update a table to 1 and once logged out it is set back to 0. The reason I did it this way was to avoid using cookies.

My problem is that when someone closes the browser it doesn't set that flag back to 0. They are still logged in. Any ideas on how to log these users out? Should I set an activity stamp and check against that?

#2
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
You can check for browser close-down, using JavaScript - but nowadays many people have JavaScript disabled, so it wouldn't work for everyone. IMO would the best solution be to make the timestamp, you was talking about. Then check it with a fixed amount of time, and if the user hasn't been active, you would set the flag to zero.

#3
Saint

Saint

    Learning Programmer

  • Members
  • PipPipPip
  • 63 posts
I believe the time stamp would work. If they were not active for over 30 minutes or so then you could remove it. You could create a variable or time stamp in your DB. Everytime they move to a new page the time stamp gets reset so you can determine if they are active or not.
Hi >> Saint

#4
Ronin

Ronin

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 309 posts
That is basically what I did and it works fine for now. :)