Hi, I read that we can use both: session('key') and session->{key} ...in order to get a value from the session. I tried: template 'login', { message => session->{flash} }; but it didn't work. However, the following worked: template 'login', { message => session('flash') }; --Octavian
In Dancer2, you can't access the session object data directly like that anymore. You can use the API described in Dancer2::Core::Session, though. David On Mar 17, 2013 11:08 AM, "Octavian Rasnita" <orasnita@gmail.com> wrote:
Hi,
I read that we can use both:
session('key') and session->{key}
...in order to get a value from the session.
I tried:
template 'login', { message => session->{flash} };
but it didn't work. However, the following worked:
template 'login', { message => session('flash') };
--Octavian
______________________________**_________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/**mailman/listinfo/dancer-users<http://lists.preshweb.co.uk/mailman/listinfo/dancer-users>
Aha, ok, thank you. It was a nice syntax though. From: David Golden In Dancer2, you can't access the session object data directly like that anymore. You can use the API described in Dancer2::Core::Session, though. David On Mar 17, 2013 11:08 AM, "Octavian Rasnita" <orasnita@gmail.com> wrote: Hi, I read that we can use both: session('key') and session->{key} ...in order to get a value from the session. I tried: template 'login', { message => session->{flash} }; but it didn't work. However, the following worked: template 'login', { message => session('flash') }; --Octavian _______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users ------------------------------------------------------------------------------ _______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
But it violates encapsulation. If you really want to do that you can do session->data->{key}, but using the API is preferred. David On Sun, Mar 17, 2013 at 11:57 AM, Octavian Rasnita <orasnita@gmail.com> wrote:
Aha, ok, thank you. It was a nice syntax though.
From: David Golden
In Dancer2, you can't access the session object data directly like that anymore.
You can use the API described in Dancer2::Core::Session, though.
David
On Mar 17, 2013 11:08 AM, "Octavian Rasnita" <orasnita@gmail.com> wrote:
Hi,
I read that we can use both:
session('key') and session->{key}
...in order to get a value from the session.
I tried:
template 'login', { message => session->{flash} };
but it didn't work. However, the following worked:
template 'login', { message => session('flash') };
--Octavian
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
________________________________
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- David Golden <xdg@xdg.me> Take back your inbox! → http://www.bunchmail.com/ Twitter/IRC: @xdg
On Sun, 17 Mar 2013 11:19:54 -0400 David Golden <xdg@xdg.me> wrote:
In Dancer2, you can't access the session object data directly like that anymore.
I really need to find time to write up a definitive "differences from Dancer1" document to ship with D2, to explain little gotchas like this. Hoping to find some time this coming week to sit down and do some serious documentation work.
I guess in session('key'), session is a DSL method. internally, it calls the session->read($key) for you. On Sun, Mar 17, 2013 at 10:07 AM, Octavian Rasnita <orasnita@gmail.com>wrote:
Hi,
I read that we can use both:
session('key') and session->{key}
...in order to get a value from the session.
I tried:
template 'login', { message => session->{flash} };
but it didn't work. However, the following worked:
template 'login', { message => session('flash') };
--Octavian
______________________________**_________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/**mailman/listinfo/dancer-users<http://lists.preshweb.co.uk/mailman/listinfo/dancer-users>
participants (4)
-
David Golden -
David Precious -
Hao Wu -
Octavian Rasnita