<div dir="ltr"><div><div>Hi all<br><br></div>I converted my Dancer app to Dancer2 and have no issues when using Dancer2::Session::Simple. Sessions persist across routes.<br><br>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.<br>
<br></div><div>Any ideas? I don't see any errors from Dancer.<br></div><div><br></div><div>Details:<br><br></div><div>Dancer2 (0.03)<br><br></div><div> cd /srv/web/app1/core/<br></div><div> setuidgid web1 ./bin/<a href="http://app.pl">app.pl</a><br>
<br></div><div>Tokyo Cabinet 1.4.48<br></div><div>Tokyo Tyrant 1.1.41<br><br></div><div> setuidgid web1 ttserver -host /srv/web/app1/sock/sessions.sock -port 0 /srv/web/app1/data/casket.tch<br></div><div><br></div><div>pertinent part of config.yml<br>
<br>logger: "console"<br>log: "core"<br>warnings: 1<br>show_errors: 1<br><br>session: Memcached<br><br>engines:<br> session:<br> Memcached:<br> memcached_servers: /srv/web/app1/sock/sessions.sock<br>
<br></div><div>This works:<br><br></div><div>post '/login' => sub {<br></div><div> if (authen(params->{'user'}, params->{'pass'}) {<br></div><div> session 'user' => params->{'user'};<br>
</div><div> return 'user = ' . session('user');<br></div><div> }<br></div><div> else {<br></div><div> return redirect '/login';<br></div><div> }<br></div><div>}<br></div><div><br></div><div>
These 2 routes always end up back at /login:<br><br><div>post '/login' => sub {<br></div><div> if (authen(params->{'user'},params->{'pass'}) {<br></div><div> session 'user' => params->{'user'};<br>
</div><div> return redirect '/dashboard';<br></div><div> }<br></div><div> else {<br></div><div> return redirect '/login';<br></div><div> }<br></div><div>}<br></div><div><br></div></div><div>get '/dashboard' => sub {<br>
</div><div> if (not session('user')) {<br></div><div> return redirect '/login';<br></div><div> }<br></div><div> # do something<br></div><div>}<br></div><div><br></div><div>Even replacing the last route with the following, leaves an empty session (i.e. user is BLANK).<br>
<br><div>get '/dashboard' => sub {<br></div><div> return 'user is ' . session('user');<br></div><div>}<br></div><div><br></div>Dale<br></div><div><br></div><div><br></div></div>