470,591 Members | 2,137 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

cgi / cookie help

Joe
I want to be able to detect if I can write cookies out or not.

Currently I'm doing:

my $cgi = new CGI;

my $cookie = $cgi->cookie(-name => $POLL_CODE_TEST,
-value => "cookietest",
-expires => "1d",
-path => '/',
-domain => $COOKIE_REALM);

print $cgi->cookie($POLL_CODE_TEST);

Now this doesn't work. Even when you can write out cookies,
$cgi->cookie($POLL_CODE_TEST) doesn't give me it back. Now I'm
guessing that the CGI object doesn't acturally write out the cookies
until it's destructor... So I tried it in a different scope but that
didn't work. Maybe I don't understand perl scope, which is very
possible.
What am I missing, and is there a better way to test you can write out
cookies?

Thankyou for anyhelp.
Jul 19 '05 #1
1 1978
In article <65**************************@posting.google.com >, Joe
<ja*****@www.com> wrote:
I want to be able to detect if I can write cookies out or not.

Currently I'm doing:

my $cgi = new CGI;

my $cookie = $cgi->cookie(-name => $POLL_CODE_TEST,
-value => "cookietest",
-expires => "1d",
-path => '/',
-domain => $COOKIE_REALM);

print $cgi->cookie($POLL_CODE_TEST);

Now this doesn't work. Even when you can write out cookies,
$cgi->cookie($POLL_CODE_TEST) doesn't give me it back. Now I'm
guessing that the CGI object doesn't acturally write out the cookies
until it's destructor... So I tried it in a different scope but that
didn't work. Maybe I don't understand perl scope, which is very
possible.
What am I missing, and is there a better way to test you can write out
cookies?
Cookies are printed to standard output with the header, i.e. when you
do:

print $cgi->header(-cookie=>$cookie);

If you want to see what you are sending to the client, do

print $cookie,"\n";

You can always write out cookies in the header. Whether or not the
client accepts them and sends them back with subsequent queries is
something else. You have to check $cgi->cookie("$POLL_CODE_TEST") in
the next query in your example to see if you get back what was sent.

Thankyou for anyhelp.

FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future.
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Ajay | last post: by
5 posts views Thread by AHN | last post: by
6 posts views Thread by kelvlam | last post: by
5 posts views Thread by mosscliffe | last post: by
16 posts views Thread by Stevo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.