I am in the process of changing my cookies (stored on my users’ browsers) so they can be shared across multiple servers under my domain. So, instead of writing cookies with domain ‘www.mydomain.com’, I am writing them to ‘.mydomain.com’ so they can be read by www.mydomain.com, www2.mydomain.com etc. During the transition, I need to be able to retrieve cookie values stored for the main domain and the subdomain. Browsers will store cookies from ‘www.mydomain.com’ and ‘.mydomain.com’ separately, and return multiple values if the target servername matches the hierarchy. However, I cannot find a way under CGI.pm or CGI::Cookie to retrieve these multiple values – only one value is ever returned. Example, I can set 2 cookies from server www.mydomain.com using: my $cookieShort = cookie(-name=>'var', -value=>’hello_short’, -expires=>'+1M', -domain=>’.mydomain.com’) my $cookieLong = cookie(-name=>'var', -value=>’hello_long’, -expires=>'+1M', -domain=>’www.mydomain.com’) print $q->header({-cookie=>[$cookieShort, $cookieLong], -type=>'text/html', -expires=>'-1d'}) ; The client returns both values properly to this server, and I can see these passed to the ENV environment variable: print ENV{'HTTP_COOKIE'} ; > var=hello_short; var=hello_long However, using CGI.pm or CGI::Cookie only one value (the highest level domain ) is ever returned: Print $q->cookie(-name=>'var') ; > hello_short my @arrayCookies = $q->cookie(-name=>'var') ; # using array context foreach (@arrayCookies) { print "$_\n" ; } > hello_short Is there a method to get CGI.pm to fetch all the values in the request, or am I forced to use the environment variable? Fetching cookies using an array context will only bring back multiple values if they are set under a single domain.
-- To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org For additional commands, e-mail: beginners-cgi-h...@perl.org http://learn.perl.org/