<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Feb 25, 2015 at 10:48 AM, Warren Young <span dir="ltr"><<a href="mailto:wyml@etr-usa.com" target="_blank">wyml@etr-usa.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
After 1 minute of closing the tab that created the session, an ls in the sessions directory shows old session *.yml files still sitting there.  Why aren’t these disappearing?<br></blockquote><div><br></div><div>Dancer doesn't poll the filesystem to make sure sessions are still valid; in fact, it can't, because it doesn't have an event loop and simply responds to requests as they come in. Unless you send another request after closing your tab, Dancer has no idea the session has expired.<br><br></div><div>Here's what happens when you access your app again after closing the tab: your browser will see that your cookie has expired and will not send it with the request. Dancer sees the request doesn't have a cookie with a valid session ID, so it creates a new session and sends a new cookie back to your browser. Dancer has no way to know that you previously had a session that is now expired; it just sees a request with no cookie.<br></div><div><br>So it can't do any cleanup of old session files; you have to use cron or something similar as Hugues mentioned.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Second, I’ve got a pool of TCP connections to a back-end server, one per active session.  When the session is logged out normally, I can find the corresponding connection and close it, too.  But, if a session times out because it’s abandoned, my connection object never gets closed.  (I’ve put a log message in its DESTROY method, and it never occurs.)<br>
<br>
Is there a way to get Dancer to notify my code when it expires a session, so I can add some app-specific cleanup code?<br></blockquote><div><br></div></div></div><div class="gmail_extra">Again, Dancer won't know the session is expired unless the user sends another request. You'll have to set up something external to Dancer to clean up your old TCP connections and run it periodically.<br><br></div></div>