Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

( #142306=categorized answer: print w/ replies, xml ) Need Help??

Q&A > CGI programming > Why can't I access a cookie I have set? 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 ;-)

Comment on Answer: Why can't I access a cookie I have set?
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2015-07-31 04:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls