NetTalk Central

Author Topic: User close browser without log out- delete session  (Read 3732 times)

johanco123

  • Full Member
  • ***
  • Posts: 245
    • View Profile
    • Email
User close browser without log out- delete session
« on: October 12, 2016, 10:29:11 PM »
Hi
How can I delete a session if the user does not log out but only close his browser?

Is there somewhere where i can find some sample code how to check if the session is still active and if not, how can I update the webser to delete the session and not show in the webserver as logged in anymore.

Any suggestion will be appreciated.

Regards
Johan
« Last Edit: October 12, 2016, 10:33:02 PM by johanco123 »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: User close browser without log out- delete session
« Reply #1 on: October 12, 2016, 11:39:43 PM »
Hi Johan,

The server has no connection to the browser (*) - so you do not know what the user is doing on their machine.
Hence you have no idea when they navigate away from your app, close the browser, turn off their machine and so on.

this is why there is a Session Timeout setting in the WebServer procedure. It defaults to 15 minutes of inactivity.

Incidentally logging out is not the same as deleting a session - when a user logs out the session (usually) remains (unless you've set the option to Delete Session on Logout.).

(*) you could theoretically use web sockets to know when the user has left the page, but that would be very complicated to do in a reliable way. Frankly, I don't see much point in going down this road...

Cheers
Bruce


johanco123

  • Full Member
  • ***
  • Posts: 245
    • View Profile
    • Email
Re: User close browser without log out- delete session
« Reply #2 on: October 13, 2016, 01:50:11 AM »
Many tanks Bruce