[dancer-users] How to send back cookies in Dancer2 Tests?

Andrew Solomon andrew at illywhacker.net
Wed Oct 30 13:23:40 GMT 2013


If you're using "simple" sessions, you need to make sure you've only got
one process since the cookies aren't shared between processes. That is, you
probably got the cookie with one process and served the second request with
another.

With the example in this tutorial, change the starman script to set the
--workers to 1

http://perlmaven.com/getting-started-with-perl-dancer-on-digital-ocean

cheers

Andrew


On Wed, Oct 30, 2013 at 12:23 PM, Gabor Szabo <gabor at szabgab.com> wrote:

> Hi there,
>
> While testing an application I write in Dancer2 I was trying to
> test the login mechanism. For this I need to send back the cookie
> I received from the server. I have code like this:
>
>
> my $r2 = dancer_response POST => '/login',
>     params => {
>              username => $users{username},
>              password => $users{password},
>       },
> };
>
> my ($cookie) =  $r2->header('set-cookie') =~ /(dancer.session=[^;]+);/;
> diag $cookie;   #   dancer.session=UnD4WqseotQvyKMGxpoVXSUYRASXQ0TA
>
>
> my $r3 = dancer_response GET => '/', {
>     headers => [
>            [ 'Cookie' => $cookie ],
>     ],
>  };
>
>
> But the server responds to the second query as if the cookie
> was not received by it.
> The same works when using a regular browser.
>
> What am I doing wrong?
> What do I need to do in order for the  session cookie to be sent back?
>
> regards
>     Gabor
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20131030/0863143a/attachment.html>


More information about the dancer-users mailing list