[dancer-users] Debugging sessions
Nikola Mitev
nik at mitev.eu
Wed Nov 21 17:17:18 GMT 2018
Hi all,
I have an annoyingly intermittent problem where on successful
authentication the session info disappears and the user is endlessly
redirected to the login page. It happens about once a month on a site
with 10-20 logins daily. Once it happens to a user, it keeps happening
for that user only. A restart of the app usually fixes the issue, and I
am yet to see someone who had this problem to report it again at a
later stage. Had about 10 cases so far in total.
The cookie is generated on accessing the login page, stored in the
browser and sent with the login POST request so I can verify cookies
are enabled. The user is then authenticated, data added to the session
including an 'authenticated' flag and they are redirected to their
dashboard. Right before the redirection the session data is present.
They make a request for the dashboard following the redirect, this
triggers a session authenticated check which fails as no data is
available for the session. They are then redirected for authentication
and so on in a loop. If I restart the app the issue vanishes.
hook before => sub {
# <snip>
if (!session('authenticated')) {
forward '/login';
}
}
post '/login' => sub {
# user authentication and session storage here, then the debug
code and the redirecton:
my $authenticated = session('authenticated');
$log->info("User authenticated ($authenticated), redirecting to
$target_route");
return redirect $target_route;
};
I don't have an explicit check on cookie size - not sure how to check
it doesn't exceed 4K - but find it unlikely this is the issue. If that
was the problem it should be happening persistently for a user
regardless of restarts etc?
Hope all this makes sense, I am looking for general advice on how to
troubleshoot this but any ideas at all will be very much appreciated.
Nik
More information about the dancer-users
mailing list