Session expiration

session-timeout

if I am logged in on my application but if i choose closing browser without clicking on logout how will be I logged out from server automatically?

Best Solution

Unless you have the user explicity log out, your server cannot know the user has closed their browser.

You can simply let sessions timeout naturally, for example, after ten minutes of inactivity.

Alternatively, you can add some js to the page to make regular pings back to the server to keep a session alive while the browser window is open.

Related Question