> Franki wrote: > > > Hi all, > > I am trying to get a perl script that sets and retrieves cookies working in >activeperl... > > The script works great on linux, but win2000, activeperl 5.6 and IIS5 doesn't like >it, no cookie set or retrieved... > > The script used the old cookie-lib.pl, and I thought that might somehow be the cause >of the problem, so I am trying to port it over to CGI::Cookie. > I am looking at the documentation for CGI::Cookie, and I have tried to make it >work.... as follows.. > > Here is the code I have so far, (again, on a linux box, this sets the cookie, >(although I have somehow clagged it from retrieving it..) > > Anyway, none of this works in win2000,,, and the retrival doesn't work properly in >Linux. > > Any ideas anyone ??? > > Kindest regards > > frank > > The Nasty code in Question... > > sub SetCookies > { > use CGI qw/:standard/; > use CGI::Cookie; > > > > $cookie{'cart_id'} = "$cart_id"; > > # Set the domain to be correct for your domain > > $domain = $sc_domain_name_for_cookie; > $secureDomain = $sc_secure_domain_name_for_cookie; > > # The path to your 'store' directory > > $path = $sc_path_for_cookie; > $securePath = $sc_secure_path_for_cookie; > > # Leave this as is. > > $secure = ""; > > # Cookie will expire in 24 hours > > $now = time; > > # Second in twenty four hours > > $twenty_four_hours = "86400"; > > $expiration = $now+$twenty_four_hours;#number of days until cookie expires > > > if(!$form_data{'secure'}) > { > &set_cookie($expiration,$domain,$path,$secure); > } > else > { > &set_cookie($expiration,$secureDomain,$securePath,$secure); > } > > } > >########################################################################################## > # Here we define the subs to replace cookie-lib.pl > # Sub set-cookie and sub get-cookie. > > sub set_cookie { > $cookie1 = new CGI::Cookie(-name => 'cart_id', > -value => "$cart_id", > -expires => "$expiration", > -domain => "$domain", > -path => "$path", > -secure => $secure > ); > > print "Content-type: text/html\n\n"; > print "Set-Cookie: $cookie1 \n";
1) Don't post in HTML - I almost didn't answer. 2) There may be other problems, but you can start by reversing the above two lines - the cookie must come before the blank line. > } > > sub get_cookie { > %cookies = fetch CGI::Cookie; > foreach (keys %cookies){ > $cookie{'cart_id'} = ($cookies{'value'}); > } > } -- ,-/- __ _ _ $Bill Luebkert ICQ=14439852 (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl) -/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/ _______________________________________________ Perl-Win32-Web mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web