Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Problem setting cookie using CGI::Cookie

by TexasTess (Beadle)
on Jun 05, 2003 at 08:20 UTC ( [id://263253]=note: print w/replies, xml ) Need Help??

in reply to Problem setting cookie using CGI::Cookie

I've been down this road before, see my post COOKIE HELL or something like that...anyway what was suggested in the first reply is almost certainly your problem.

Ya gotta set the cookie before any header goes out, it's got to be the first thing you do else you'll never get it to set. When I was working on getting mine to set, I would invoke a new script just so I was certain there would be no header set when I stuck it in.

"Great Spirits Often Encounter Violent Opposition From Mediocre Minds" --Albert Einstein
  • Comment on Re: Problem setting cookie using CGI::Cookie

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

    All &url does is print

    <!DOCTYPE html PUBLIC "..."> <html> ... <link rel="stylesheet" type="text/css" href="/sheet.css" media="screen +">
    Will this cause a problem.

    Sorry about not saying this sooner, but I couldn't get to the PC this was on until this morning

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

      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

        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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-16 22:35 GMT
Find Nodes?
    Voting Booth?

    No recent polls found