[dancer-users] Dancer2::Session::Memcached with Tokyo Cabinet/Tyrant not working
Dale Gallagher
dale.gallagher at gmail.com
Mon Apr 8 12:17:48 BST 2013
Hi all
I converted my Dancer app to Dancer2 and have no issues when using
Dancer2::Session::Simple. Sessions persist across routes.
However, on switching to Dancer2::Session::Memcached, after setting the
session via the /login route, it's not accessible via another route. I know
that the Memcached instance is functional, having tested it using a regular
Perl script with Cache::Memcached.
Any ideas? I don't see any errors from Dancer.
Details:
Dancer2 (0.03)
cd /srv/web/app1/core/
setuidgid web1 ./bin/app.pl
Tokyo Cabinet 1.4.48
Tokyo Tyrant 1.1.41
setuidgid web1 ttserver -host /srv/web/app1/sock/sessions.sock -port 0
/srv/web/app1/data/casket.tch
pertinent part of config.yml
logger: "console"
log: "core"
warnings: 1
show_errors: 1
session: Memcached
engines:
session:
Memcached:
memcached_servers: /srv/web/app1/sock/sessions.sock
This works:
post '/login' => sub {
if (authen(params->{'user'}, params->{'pass'}) {
session 'user' => params->{'user'};
return 'user = ' . session('user');
}
else {
return redirect '/login';
}
}
These 2 routes always end up back at /login:
post '/login' => sub {
if (authen(params->{'user'},params->{'pass'}) {
session 'user' => params->{'user'};
return redirect '/dashboard';
}
else {
return redirect '/login';
}
}
get '/dashboard' => sub {
if (not session('user')) {
return redirect '/login';
}
# do something
}
Even replacing the last route with the following, leaves an empty session
(i.e. user is BLANK).
get '/dashboard' => sub {
return 'user is ' . session('user');
}
Dale
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20130408/5a55a643/attachment.htm>
More information about the dancer-users
mailing list