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

Answer: Why can't I access a cookie I have set?

by simon.proctor (Vicar)
on Jan 31, 2002 at 23:33 UTC ( #142546=categorized answer: print w/replies, xml ) Need Help??

Q&A > CGI programming > Why can't I access a cookie I have set? - Answer contributed by simon.proctor

Referring to the CGI documentation, the following example is presented.
$cookie = $query->cookie(-name=>'sessionID', -value=>'xyzzy', -expires=>'+1h', -path=>'/cgi-bin/database', -domain=>'.capricorn.org', -secure=>1); print $query->header(-cookie=>$cookie);

I would recommend that you read the pod for CGIand use the code presented there. As a pointer, I would stick to the CGI module and not use CGI::Cookie. I say this as I've had no end of problems with CGI::Cookie in the past that disappeared once CGI was used instead.

Note that the code example assumes you have already created a CGI query object.

Hope that helps.

Replies are listed 'Best First'.
Re: Answer: Why can't I access a cookie I have set?
by cLive ;-) (Prior) on Feb 01, 2002 at 07:59 UTC
    Although your answer correctly states how to set a cookie, that was not the point I was trying to make. Several people asked why they couldn't read a cookie when they had just set it. ie, they wanted to read the cookie in the same invocation of their script.

    That was why I posted this question and answer combo.

    cLive ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[jedikaiti]: SuicideJunkie++ #Apgrade is the highest point it will reach. They're informing you that it will all be downhill from here until the software hits a PEgrade, or impacts the terrain depending on the details of the orbit.

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2017-07-25 18:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (377 votes). Check out past polls.