I am trying to add sessions to my new Dancer2 based applications and it drives me crazy as usual. In config.yml I added session: YAML in my login route I added session last_seen => time; Running the applications using plackup -L Shotgun bin/app.pl and accessing it via http://localhost:5000/ (though I get the same behaviour with perl bin/app.pl as well) after I pass the login route I see a new yml file created in the sessions/ directory but when I check my browser I don't see any cookies from localhost and when the code checks in the next get request if (session('last_seen')) it is false. My understanding is that Dancer should set a cookie with the id of the session which is the name of the yml file in the sessions/ directory. What do I need to configure in order to get this working? Gabor
Answering myself: if instead of redirect '/', I call template 'index' after setting the session, then it works as expected. (Well, except that the URL now stays as it was which is not that nice). As far as I can understand from the Dancer2 docs, this should work with redirect as well. Gabor
On 24/10/13 11:19 PM, Gabor Szabo wrote:
Answering myself: if instead of redirect '/',
Redirection is "broken" in the Dancer2 0.09 and 0.10. (broken => it flags the response as halted, so the after hook that flushes the session and adds the cookie header doesn't get called.) There is a branch that uses Return::MultiLevel that restores this functionality waiting to to be merged. Hope that helps, Russell -- This UTC+13 timezone is like living in tomorrow.
The Return::MultiLevel was merged. It should be out soon. On Fri, Oct 25, 2013 at 6:39 AM, Russell Jenkins < russell.jenkins@strategicdata.com.au> wrote:
On 24/10/13 11:19 PM, Gabor Szabo wrote:
Answering myself: if instead of redirect '/',
Redirection is "broken" in the Dancer2 0.09 and 0.10. (broken => it flags the response as halted, so the after hook that flushes the session and adds the cookie header doesn't get called.)
There is a branch that uses Return::MultiLevel that restores this functionality waiting to to be merged.
Hope that helps, Russell -- This UTC+13 timezone is like living in tomorrow.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
participants (3)
-
Gabor Szabo -
Russell Jenkins -
sawyer x