sub get_cookie { local($chip, $val); foreach (split(/; /, $ENV{'HTTP_COOKIE'})) { # split cookie at each ; (cookie format is name=value; name=value; etc...) # Convert plus to space (in case of encoding (not necessary, but recommended) s/\+/ /g; # Split into key and value. ($chip, $val) = split(/=/,$_,2); # splits on the first =. # Convert %XX from hex numbers to alphanumeric $chip =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge; $val =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge; # Associate key and value #undef($cookie{$chip}); next if (defined($cookie{$chip})); # \1 is the multiple separator #$cookie{$chip} .= "\1" if (defined($cookie{$chip})); # \1 is the multiple separator $cookie{$chip} .= $val; } } # end SR NB - the other subroutines from this library [set-cookie, split-cookie, delete-cookie] have not been included here.