For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > November 2005 > Retrieve a cookie









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Retrieve a cookie
James

2005-11-15, 9:55 pm

Try to retrieve a cookie, but gets an empty string for the cookie.

----------------------------------------------------
#!/bin/env perl -w

use CGI qw(:standard);
print "Content-type: text/html\n\n";

my $cookie = cookie( -name => 'car', -value => 'GM');

my $car = cookie('car');
print "car = $car";

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

web-page output:

car =
Set-Cookie: car=GM; path=/ Date: Wed, 16 Nov 2005 01:51:06 GMT
Content-Type: text/html; charset=ISO-8859-1

Thanks in advance.

James

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com