<div dir="ltr"><pre>Hi<br><br>Calling session->destroy fails with the following.<br></pre><pre><br>Can't locate object method "destroy" via package "Dancer2::Core::Session" at /srv/web/app/lib/<a href="http://app.pm">app.pm</a> line 36.<br>
<br>config.yml:<br><br>session: Simple<br><br></pre><pre>/srv/web/app/lib/<a href="http://app.pm">app.pm</a>:<br><br></pre><pre>package app;<br>use Dancer2 ':syntax';<br>use Dancer2::Plugin::Ajax;<br>use Authen::Simple::Passwd;<br>
<br>...<br>..<br><br></pre><pre>get '/logout' => sub {<br></pre><pre> session->destroy;<br></pre><pre> redirect '/login';<br></pre><pre>}<br><br></pre><pre>I even tried:<br><br></pre><pre>my $id = session->id;<br>
</pre><pre>session->delete($id);<br><br></pre><pre>but, even though it doesn't throw an error, it doesn't delete the session and other routes are served.<br><br></pre><pre>So far, at the top of <a href="http://app.pm">app.pm</a>, I have:<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>
session 'time' => time;<br> }<br> else {<br> return redirect '/logout?msg=session_expired&path=' . request->path_info;<br> }<br> }<br> else {<br> return redirect '/login';<br>
}<br> }<br>};<br><br><br></pre><pre>I'm stumped, as, apart from the above snippet, and the Dancer2 use lines, the app works under Dancer1.<br><br></pre><pre>Any pointers would be appreciated.<br><br></pre><pre>Thanks<br>
Dale<br></pre></div>