0

I have a online/offline program, which relies on whether the user is online or not. So is there any way to logout the user when he/she closes the window.so admin get to know the user actual login or not ? What is the right way to do this ?

Mak
  • 191
  • 1
  • 2
  • 11

2 Answers2

3

Sessions should automatically be discarded as soon as a user closes his / her browser. That is unless you have some sort of "Remember Me" functionality in place.

As far as knowing when users have logged out or not, there's no surefire way to know. Your best bet is to keep a record of their latest activity and compare that against the current time. So... if a user has been inactive for more than 30 minutes, assume that they are logged out?

Wayne Whitty
  • 19,513
  • 7
  • 44
  • 66
  • Wayne thanks for reply. i am new to php so will you please tell how can we get the last activity of user ? – Mak Oct 19 '12 at 11:05
0

Easiest way to logout.Make a popup page on unload that says" goodbye or smth." and logout and discard session on popup loading.

Sait DURU
  • 89
  • 1
  • 2
  • 11
  • if session is running and user doing his/her work then popup will show or not ? – Mak Oct 19 '12 at 11:07