[dancer-users] Dancer2::Session::Memcached with Tokyo Cabinet/Tyrant not working

Dale Gallagher dale.gallagher at gmail.com
Wed Apr 10 13:50:09 BST 2013


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 <dale.gallagher at gmail.com> 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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20130410/b9c5a391/attachment.htm>


More information about the dancer-users mailing list