Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by cLive ;-) (Prior)
on Jan 29, 2002 at 10:19 UTC ( #142306=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 cLive ;-)

Let's assume you have a CGI object:
my $q = new CGI;
Cookies are accessed through $q->cookie('name').

Cookies are sent by the browser when requesting the page. If you set a cookie in a CGI script, the cookie is sent to the browser, but not set in $q->cookie. ie,

Set == Cookie stored in browser Readable == Cookie available in $q->cookie('name') Event Set? Readable? Browser request n n Response to Browser y n Subsequent Browser y y Requests(*)

(*) - within the life of the cookie.

Just remember that $q->cookie only contains cookies sent by the browser as part of that particular http request!

Hope that clears things up a little :)

cLive ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[Eily]: choroba Wikipedia gives me Zavináč which doesn't seem to translate to something edible?
[Eily]: (yes I'm very good at using question marks, thank you)
[Discipulus]: O_O frexit for you! even me i tried. it was in the arabic quarter in Granada; they offered as 'tapas' in bars. I eataly somewhere they eat ;=P Sardinia a Pulia iirc
[choroba]: Zavináč
[Eily]: choroba oh, that makes sense :)

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2017-11-21 11:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (297 votes). Check out past polls.

    Notices?