sub setCookie { my ($expires, @cookies) = @_; my ($header); my ($cookie,$value, $char); my @cookie_encode_chars = ('\%', '\+', '\;', '\,', '\=', '\&', '\:\:', '\s'); my %cookie_encode_chars = ('\%','%25','\+','%2B','\;','%3B','\,','%2C','\=', '%3D','\&','%26','\:\:','%3A%3A','\s','+'); my @cookie_decode_chars = ('\+', '\%3A\%3A', '\%26', '\%3D', '\%2C', '\%3B', '\%2B', '\%25'); my %cookie_decode_chars = ('\+',' ','\%3A\%3A', '::','\%26','&','\%3D','=','\%2C', ',','\%3B',';','\%2B','+','\%25','%'); while(($cookie,$value)=@cookies) { foreach $char (@cookie_encode_chars) { $cookie =~ s/$char/$cookie_encode_chars{$char}/g; $value=~ s/$char/$cookie_encode_chars{$char}/g; } if ( $expires) { $header.= "Set-Cookie: $cookie=$value; expires = $expires; path=/;\n"; } shift(@cookies); shift(@cookies); } $cookie =1; return $header; } sub GetCook { my (@cookies, %cookie_hash, $cookie, $key, $val); @cookies = split (/; /,$ENV{'HTTP_COOKIE'}); foreach $cookie (@cookies) { ($key, $val) = split (/=/,$cookie); $cookie_hash{$key} = $val; } return keys(%cookie_hash); }