Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>EDIT</strong>: Looking at the link you gave, they write:</p> <blockquote> <p>We can also start the server (with “$ rails s”) and verify the functioning of our brand new session <em>without cookies (we should be</em> <em>logged out every time we close the browser).</em></p> </blockquote> <p>(emphasis added)</p> <p>Therefore, their solution is to simply turn off cookies, which results in a new session being created with each visit. They are not really talking about removing old sessions on the server side of the equation.</p> <p>My original answer is left below for historical value:</p> <hr> <p>(apologies if this is too general, I'm assuming you're not seeing the bigger picture)</p> <p>Fundamentally, the web uses a pull-based model - clients make requests to do things on the server.</p> <p>You can not 'force' the client to close a session, since closing a session is an action that the client must request from the server (eg: by logging out).</p> <p>Therefore, typically sessions have a time-out period that is checked regularly. Each session has a 'start time' stored in the database, and sessions that are too old are purged.</p> <p>That said, there may be some way in javascript to detect a browser close event and make some best-effort attempt to close the session. But there is no guarantee - the user can always forcefully kill the browser process, leaving the server totally in the dark.</p> <p>In short, you can't rely on the client to close a session. A timeout is probably your best option.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload