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