Thanks David, that resolved it.
On 9 April 2013 12:46, David Golden <[email protected]> wrote: > The session paradigm changed in D2. Session objects are now just data > objects, so you have to destroy them via the context object, which > dispatches to the configured session engine and does some other > necessary bookkeeping: > > context->destroy_session > > -- David > > On Tue, Apr 9, 2013 at 6:36 AM, Dale Gallagher <[email protected]> > wrote: > > Hi > > > > Calling session->destroy fails with the following. > > > > > > Can't locate object method "destroy" via package > "Dancer2::Core::Session" at > > /srv/web/app/lib/app.pm line 36. > > > > > > config.yml: > > > > session: Simple > > > > /srv/web/app/lib/app.pm: > > > > package app; > > use Dancer2 ':syntax'; > > use Dancer2::Plugin::Ajax; > > use Authen::Simple::Passwd; > > > > > > ... > > .. > > > > get '/logout' => sub { > > > > session->destroy; > > > > redirect '/login'; > > > > } > > > > I even tried: > > > > my $id = session->id; > > > > session->delete($id); > > > > but, even though it doesn't throw an error, it doesn't delete the session > > and other routes are served. > > > > So far, at the top of app.pm, I have: > > > > > > hook before => sub { > > if (request->path_info !~ m{^/login}) { > > if (session('user') && session('time')) { > > my $time_now = time; > > if ($time_now - session('time') < config->{'session_expire'}) { > > > > session 'time' => time; > > } > > else { > > return redirect '/logout?msg=session_expired&path=' . > > request->path_info; > > } > > } > > else { > > return redirect '/login'; > > > > } > > } > > }; > > > > > > I'm stumped, as, apart from the above snippet, and the Dancer2 use lines, > > the app works under Dancer1. > > > > Any pointers would be appreciated. > > > > Thanks > > > > Dale > > > > > > _______________________________________________ > > dancer-users mailing list > > [email protected] > > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > > > > > > -- > David Golden <[email protected]> > Take back your inbox! → http://www.bunchmail.com/ > Twitter/IRC: @xdg > _______________________________________________ > dancer-users mailing list > [email protected] > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users >
_______________________________________________ dancer-users mailing list [email protected] http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
