Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Re: Problem setting cookie using CGI::Cookie

by chromatic (Archbishop)
on Jun 05, 2003 at 16:29 UTC ( #263403=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Problem setting cookie using CGI::Cookie
in thread Problem setting cookie using CGI::Cookie

Yes, that will cause a problem if you print it before the header. The header must come first. The cookie must be in the header. If you print anything else first and the web browser accepts the cookie, it's broken.

Your web server may add headers automatically if you don't print the headers first, but your cookie won't be set if that happens. You get one chance to print the HTTP header and the cookie must be in that header.

I'm being very explicit here because this trips up a lot of people.

As far as the domain issue, you may need to add a trailing period. I seem to recall that CGI::Cookie checks to see if the domain name contains two periods. Does it work better with example.com.?

Replies are listed 'Best First'.
Re: Re: Re: Re: Problem setting cookie using CGI::Cookie
by kutsu (Priest) on Jun 05, 2003 at 16:45 UTC

    The cookie is only sent if the username is correct and ,if it is, does print before the header. Maybe my script doesn't show that well?

    "Pain is weakness leaving the body, I find myself in pain everyday" -me

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://263403]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2023-12-03 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (20 votes). Check out past polls.

    Notices?