get cookie?

merlin's picture

They have: 410 posts

Joined: Oct 1999

the whole day i'm already working on that, knowing, it can't be THIS difficult.

here we go:
i have a cookie set like this .
when a visitor comes back to the page, i'd like to receive the data of the cookie and put it into some form-fields, each cookie in one.
i tried to split up $ENV{'HTTP_COOKIE'}:

foreach $env_cookie ($ENV{'HTTP_COOKIE'}) {
@allcookies = split (/\* /, $env_cookie);
}
'
and put it into several $:
foreach $cookie (@allcookies) {
($titlecookie,$storycookie) = split(/;/);
}
$cookie = "";
my ($titlecookiename, $titlecookievalue);
foreach $cookie ($titlecookie) {
($titlecookiename,$titlecookievalue) = split(/=/, $cookie);
}
$cookie = "";
my ($storycookiename, $storycookievalue);
foreach $cookie ($storycookie) {
($storycookiename,$storycookievalue) = split(/=/, $cookie);
}
'

but somehow, it doesn't do it. i check it with print, and it only prints the $ENV{'HTTP_COOKIE'}-thingy.

what am i doing wrong? am i going the right way or do i miss any important thing?

thank you for your help!
Laughing out loud ali

merlin's picture

They have: 410 posts

Joined: Oct 1999

i knew it couldn't be that hard!
what was wrong: i tried to get the cookie in a seperate sub. well, that didn't work, i had to do it in the same sub as i print out the form.
but i suppose, there must be a way to get the cookie in another sub?

$titlecookie = $query->cookie("cookiename1");
$storycookie = $query->cookie("cookiename2");
'

thanks for your patience... Smiling

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.