
LanceLovesJia
New User
Mar 4, 2003, 1:34 AM
Post #1 of 5
(710 views)
|
|
persistent cookies
|
Can't Post
|
|
can anyone explain to me how i can retrieve persistent cookies from a user's web browser? i can't seem to get this to work #- Set Cookie -----------------------------------------------------------------# sub setCookie { # end a set-cookie header with the word secure and the cookie will only # be sent through secure connections local($name, $value, $expiration, $path, $domain, $secure) = @_; print "Set-Cookie: "; print ($name, "=", $value, "; expires=", $expiration, "; path=", $path, "; domain=", $domain, "; ", $secure, "\n"); } #------------------------------------------------------------------------------# #- Retrieve Cookies From ENV --------------------------------------------------# sub getCookies { # cookies are seperated by a semicolon and a space, this will split # them and return a hash of cookies local(@rawCookies) = split (/; /,$ENV{'HTTP_COOKIE'}); local(%cookies); foreach(@rawCookies){ ($key, $val) = split (/=/,$_); $cookies{$key} = $val; } return %cookies; } #------------------------------------------------------------------------------# # be sure to print a MIM type AFTER cookie headers and follow with a blank line print "Content-type: text/html\n\n"; # this is the first thing the user sees in the browser print "\nReload for Cookies:<BR>"; %cookies = &getCookies; # store cookies in %cookies foreach $name (keys %cookies) { print "\n$name = $cookies{$name}<br>"; } #------------------------------------------------------------------------------# this is taken from http://www.bewley.net/perl/ can anyone explain to me why my browser is nto displaying the cookies name and stuff?
|