[dancer-users] Session expiration cleanup

Hugues hugues at max4mail.com
Wed Feb 25 18:02:19 GMT 2015


Hello Warren
your *.yml will never disappear , you can remove it with simple crontab 
script
or use other session engine ( like Redis )

I do not use session_expires but a simple hook

hook 'before' => sub {

my $sessionDuration = 14400;  # in second

if (session('Time') && session('Time') + $sessionDuration < time()) {
                 var requested_path => request->path_info;
                 request->path_info('/disconnect');
         }
};

.............


get '/disconnect' => sub {
                 my $time     = session('Time');
                 my $username = session('username');
                 session->destroy();
};

Le 25/02/2015 18:48, Warren Young a écrit :
> I’m seeing two problems with session cleanup in Dancer 1.
>
> I’m testing with YAML sessions and a purposely short session timeout:
>
>     session_expires: "1 minute”
>     session: “YAML"
>
> 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?
>
> 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.)
>
> 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?
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

-- 
Salutations



More information about the dancer-users mailing list