Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with reading cookies

Status
Not open for further replies.

alarge23

Programmer
Oct 26, 2003
50
US
I am new to Perl and need help with my code. The following code will set cookies ok, but will not read them. Why not?

#!/perl/bin -w
use strict;
use CGI qw:)standard);

my $cookie_in = ' ';
my $query = new CGI;
my $set_cookie1 = $query->cookie(-name=>"hotdog",
-value=>"2");
my $set_cookie2 = $query->cookie(-name=>"fries",
-value=>"3");

$cookie_in = $query->cookie("hotdog");

if ($cookie_in)
{ print "Value for hotdog in cookies: $cookie_in\n"; }
else
{ print "Can't find hotdog cookies.\n"; }
 
When you set a cookie it may not be immediately readable until the next transaction.

Try not setting it everytime and see what happens.
 
siberian,

Thanks for the help, but it still doesn't appear to work. Any more suggestions?
In the mean time, I have found a work around, by using javascript to set/read cookies instead. I would still like to learn to do this with perl.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top