*alexandre* has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I'm still porting existing app into window 10 env, I cannot create a coookie while using this code :
#!"C:\xampp\perl\bin\perl.exe" use warnings; use CGI; use CGI::Cookie; my $query = CGI->new ; my $cookie = CGI::Cookie->new(-name => 'USERNAME', -value => 'Test Cookie', -expires => '+3M', -domain => 'avant-garde.no-ip.biz', -path => '/', -secure => 1); loadPersonalData(); sub loadPersonalData { my $cookie_in = $query->cookie('USERNAME'); print "Content-Type: text/html\n\n"; print "test : $cookie_in"; }
thx =)

Replies are listed 'Best First'.
Re: cookie not create under windows 10
by hippo (Archbishop) on Jun 24, 2019 at 12:37 UTC

    You haven't set the cookie in a header so the browser won't receive it (assuming that's what you mean by "cannot create"). I wrote an example script for another user a while ago - see Re^5: auto create cookies. Since you are using CGI.pm you can use the header method to set the cookie if you prefer.

      Full thx it's working fine rigth now =)
Re: cookie not create under windows 10
by Corion (Patriarch) on Jun 24, 2019 at 12:34 UTC

    Have you made sure that your browser actually sends the cookie? Is the domain of your server the same domain that the browser has stored?

    If you want to SET a cookie in the browser, you will need to learn about how to do that. This will involve actually printing the appropriate Set-Cookie header.

    Maybe you want to start out with something simpler, like maybe Mojolicious or Dancer, which already have session and cookie handling built in for you?