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

Gabor Szabo gabor at szabgab.com
Wed Oct 30 12:23:50 GMT 2013

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?


More information about the dancer-users mailing list