<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">&lt;<a href="mailto:xdg@xdg.me" target="_blank">xdg@xdg.me</a>&gt;</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-&gt;destroy_session<br>
<br>
-- David<br>
<div><div class="h5"><br>
On Tue, Apr 9, 2013 at 6:36 AM, Dale Gallagher &lt;<a href="mailto:dale.gallagher@gmail.com">dale.gallagher@gmail.com</a>&gt; wrote:<br>
&gt; Hi<br>
&gt;<br>
&gt; Calling session-&gt;destroy fails with the following.<br>
&gt;<br>
&gt;<br>
&gt; Can&#39;t locate object method &quot;destroy&quot; via package &quot;Dancer2::Core::Session&quot; at<br>
&gt; /srv/web/app/lib/<a href="http://app.pm" target="_blank">app.pm</a> line 36.<br>
&gt;<br>
&gt;<br>
&gt; config.yml:<br>
&gt;<br>
&gt; session: Simple<br>
&gt;<br>
&gt; /srv/web/app/lib/<a href="http://app.pm" target="_blank">app.pm</a>:<br>
&gt;<br>
&gt; package app;<br>
&gt; use Dancer2 &#39;:syntax&#39;;<br>
&gt; use Dancer2::Plugin::Ajax;<br>
&gt; use Authen::Simple::Passwd;<br>
&gt;<br>
&gt;<br>
&gt; ...<br>
&gt; ..<br>
&gt;<br>
&gt; get &#39;/logout&#39; =&gt; sub {<br>
&gt;<br>
&gt;   session-&gt;destroy;<br>
&gt;<br>
&gt;   redirect &#39;/login&#39;;<br>
&gt;<br>
&gt; }<br>
&gt;<br>
&gt; I even tried:<br>
&gt;<br>
&gt; my $id = session-&gt;id;<br>
&gt;<br>
&gt; session-&gt;delete($id);<br>
&gt;<br>
&gt; but, even though it doesn&#39;t throw an error, it doesn&#39;t delete the session<br>
&gt; and other routes are served.<br>
&gt;<br>
&gt; So far, at the top of <a href="http://app.pm" target="_blank">app.pm</a>, I have:<br>
&gt;<br>
&gt;<br>
&gt; hook before =&gt; sub {<br>
&gt;   if (request-&gt;path_info !~ m{^/login}) {<br>
&gt;     if (session(&#39;user&#39;) &amp;&amp; session(&#39;time&#39;)) {<br>
&gt;       my $time_now = time;<br>
&gt;       if ($time_now - session(&#39;time&#39;) &lt; config-&gt;{&#39;session_expire&#39;}) {<br>
&gt;<br>
&gt;         session &#39;time&#39; =&gt; time;<br>
&gt;       }<br>
&gt;       else {<br>
&gt;         return redirect &#39;/logout?msg=session_expired&amp;path=&#39; .<br>
&gt; request-&gt;path_info;<br>
&gt;       }<br>
&gt;     }<br>
&gt;     else {<br>
&gt;       return redirect &#39;/login&#39;;<br>
&gt;<br>
&gt;     }<br>
&gt;   }<br>
&gt; };<br>
&gt;<br>
&gt;<br>
&gt; I&#39;m stumped, as, apart from the above snippet, and the Dancer2 use lines,<br>
&gt; the app works under Dancer1.<br>
&gt;<br>
&gt; Any pointers would be appreciated.<br>
&gt;<br>
&gt; Thanks<br>
&gt;<br>
&gt; Dale<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; dancer-users mailing list<br>
&gt; <a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
&gt; <a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
&gt;<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
David Golden &lt;<a href="mailto:xdg@xdg.me">xdg@xdg.me</a>&gt;<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>