Given that no-one has replied to this thread yet, could someone perhaps share an example of how they use Dancer2::Session::Memcached for sessions?
I was hoping to continue building my app in Dancer2, but it seems I may be better off reverting to Dancer at this stage, especially given many inconsistencies in the docs versus changes in Dancer2. Thanks. On 8 April 2013 13:17, Dale Gallagher <[email protected]> wrote: > 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 > > >
_______________________________________________ dancer-users mailing list [email protected] http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
