[cgiapp] Using CGI::Cookie from inside CGI::Application

CGI User cgiapp at mailswamp.com
Wed May 21 18:09:42 EDT 2008


Thank you,
I got it.

If I form cookie like this:
my $cookie = $q->cookie( -name=>$cook_name, -value=>$sess_id, -expires=>$cook_exp);

$self->header_add(-cookie => $cookie);

Everything works honky dory.

But if I form cookie like this:
my $cookie = $q->cookie( -name=>$cook_name, -value=>$sess_id, 
-expires=>$cook_exp, -domain=>'.'.$domain, -path=>'/');

It doesn't work at all.

I wonder to know why and how I can set at least domain into cookie.
In the CGI.pm pod I clearly read this:

The interface to HTTP cookies is the cookie() method:

     $cookie = cookie(-name=>'sessionID',
                              -value=>'xyzzy',
                              -expires=>'+1h',
                              -path=>'/cgi-bin/database',
                              -domain=>'.capricorn.org',
                              -secure=>1);
     print header(-cookie=>$cookie);


Then why there is such a discrepancy between my practical case and CGI.pm pod?
Go figure ...

Alex




Alexandr Ciornii wrote:
> Hello.
> 
> 1. Try removing
>        -domain     => '.come_domain.com',
> in addition to other changes.
> 2. Try removing all except '-name',  '-value', '-expires' parameters.
> and make expires bigger like '+20h'.
> 
> 
> 2008/5/21 CGI User <cgiapp at mailswamp.com>:
>> Hi Sasha,
>> Thanks for the hints.
>> However, even if I replace '+1H' with '+1h' and don't set secure flag
>> the cookie still doesn't show up in the browser.
> 



More information about the cgiapp mailing list