[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Cookie wierdness?
From:       "John S. Evans" <jsevans () alumni ! stanford ! org>
Date:       1999-06-29 17:05:49
[Download RAW message or body]

(Apache 1.3.6, modperl 1.20)

I'm writing an authorization handler, and am having some problems accessing
cookies. Using the various methods of cookie access, I can sometimes get the
cookie just fine (but the value is not what I expected), and other times not
get the cookie value at all.

Here's how the cookie is created:

 	$cookie = CGI::Cookie->new(-name => 'mycookie',
		-value => 'foobar',
		-path => "/");

I set my browser to show me when a cookie is returned, and sure enough, I
see the value of the cookie is "foobar".

When I go to access the cookie in the auth handler, I print out the value of
the entire cookie rhs.  I see "mycookie=foobar" (which is correct, I think).

That's when things start to break down.  I try two different methods of
getting the cookie value, both described in the modperl book on page 209.

When I access the cookie value with this code, I get a cookie value, but
it's not what I expected:

	%cookieList = CGI::Cookie->parse($r->header_in('Cookie'));
	$cookieValue = $cookieList{'mycookie'};

I expected the cookie_value to be "foobar", but it was actually
"mycookie=foobar".  Is this the expected behavior (it isn't form the
examples I've seen).

When I access the cookie value with this code, I don't get any cookie value:

	$cookie_value = cookie('mycookie');


Any clues?  I've looked through the mailing list archives, and didn't see
any problems that looked similar.  I don't really care which access method I
use, as long as the results are predictable...

-jse

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic