develooper Front page | perl.beginners | Postings from March 2002

Re: Cookies, What's wrong with this?

Thread Previous
Johannes Franken
March 3, 2002 08:06
Re: Cookies, What's wrong with this?
Message ID:
On Sun, Mar 03, 2002 at 07:20:35AM -0500, wrote:
> Could someone tell me why this doesn't retrieve my cookie?
> use CGI param, header,cookie;
> print header();
> print header(-cookie=>'MY_COOKIE');

header() is for generating an http header, not for reading from it.
print cookie('MY_COOKIE') instead.

Quoting the CGI manpage:

	To retrieve a cookie, request it by name by calling
	cookie() method without the -value parameter:

	use CGI;
	$query = new CGI;
	%answers = $query->cookie(-name=>'answers');
	# $query->cookie('answers') will work too!
Johannes Franken
Professional unix/network development

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About