can't retrieve all cookies with cgi.pm

ironmann_at_conwaycorp.net
Date: 12/19/04


Date: 18 Dec 2004 22:16:12 -0800

I have been struggling with this for a long time and I just can't
figure it out. I thought that you might look at it and see right away
what the problem is. When I do the following, I know the cookie gets
set correctly (because I print it out on the screen)...but when I go to
retrieve it, all I can get are the username and the alias cookies. The
sess_id doesn't get retrieved...but the alias and username do.

$numDigits = 20;

srand(time|$$);

@charList = ('a'..'z','A'..'Z',0..9);

$id = "";

for($x=0; $x<$numDigits; $x++) { $id .= $charList[int(rand(64))]; }

$sess_id = $id .= time();

$sess_id_cookie = cookie(-name => 'sess_id', -value
=>$sess_id, -expires=>);

$username_cookie = cookie(-name => 'username', -value
=>$username, -expires=>);

$alias_cookie = cookie(-name => 'alias', -value
=>$alias, -expires=>);

print header (-cookie => [$sess_id_cookie, $username_cookie,
$alias_cookie]);

my $sess_username_cookie = cookie('username');

my $sess_id_cookie = cookie('sess_id');

my $alias = cookie('alias');

If I do the following and set just one cookie with all three things
within it, I can not reitieve any of the information from the
cookie...but I know that the cookie is being set with the information
inside it. I create the cookie in one script and try to retrieve it in
another. Do you have any ideas at all? The first way above is the
most troubling because I set 3 cookies and two of them get retrieved
and 1 doesn't.

$credentials_cookie = cookie(-name => 'credentials',

-value=>{
sess_id=>$sess_id,

username=>$username,

alias=>$alias
},

-expires=>,

-path =>'/'

);

print header (-cookie => $credentials_cookie);

%credentials_cookies = cookie('credentials');

$alias = $credentials_cookies{alias};

$sess_id = $credentials_cookies{sess_id};
$username = $credentials_cookies{username};



Relevant Pages