[dancer-users] Handling cookies on D2

David Precious davidp at preshweb.co.uk
Fri Apr 19 18:12:22 BST 2013


On Fri, 19 Apr 2013 19:39:02 +0300
Punter <punter at punter.gr> wrote:

> My inspiration for this pull request was this supposed documentation 
> that describes how the "cookie" keyword works: 
> https://github.com/PerlDancer/Dancer2/blob/ea7bc77993277f34fcd27f3eb7b01366877a7d23/lib/Dancer2/Manual/Keywords.pod

Yes, the manual still needs some work.  You're looking at unfinished
work on my branch.  That's why it's not shipped with Dancer2 yet.

Looking at the Dancer2 code, you'll get Dancer2::Core::Cookie objects
back.

That's the design, and I'm not aware of any plans for it to change.

You can fetch a cookie with:

my $cookie = cookie 'foo';
my $value = $cookie->value;

One change that I think would be valuable actually would be to have
Dancer2::Core::Cookie use overloading, so that a Dancer2::Core::Cookie
object stringifies to its value - a bit of DWIMmery.

I'll look in to that and discuss it with the rest of the team.

Cheers

Dave P


-- 
David Precious ("bigpresh") <davidp at preshweb.co.uk>
http://www.preshweb.co.uk/     www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan        www.preshweb.co.uk/github




More information about the dancer-users mailing list