jna wrote: >>jna wrote: >> >> >>>Hello, >>> >>>Is anyone using CGI.pm and the built in cookie routine? I just >>> > implemented > >>>it on one of my websites storing username and password and retrieving it >>> > for > >>>user identification. Problem is it works for me and for alot of other >>> > people > >>>but there are a large group of people who it is NOT working for? Has >>> > anyone > >>>experienced a split in browser ability with CGI.pm and its cookies? Is >>> > this > >>>a bug or is anyone aware of it? I am certain it cant be my code, else it >>>wouldnt work at all? >>> >>>Snippets: >>> >>>To issue cookie: >>> >>>$the_cookie = $cgi->cookie(-name=>'userdata', >>> -value=>\%userdata, >>> -expires=>'+15m', >>> -path=>'/cgi-bin/path', >>> -domain=>'.thedomain.com', >>> -secure=>0); >>>print $cgi->header(-cookie=>$the_cookie); >>> >>>to grab cookie: >>> >>>$user = ""; >>>$pass = ""; >>>%userdata = $cgi->cookie('userdata'); >>>foreach ('userid','password','expires') { >>> $userdata{$_} = $cgi->param($_) || $userdata{$_}; >>>} >>>$user = $userdata{'userid'}; >>>$pass = $userdata{'password'}; >>>$expires = $cgi->cookie('expires'); >>> >>>Any thoughts or ideas ? >>> >> >>Using a hash for the cookie value is going to concatenate them all >> >>together with &'s. I would either use multiple cookies or concatenate >>the hash together myself into $value and pass it that way. I'm not >>sure what the intent was for using a hash for the cookie value. >> >> > Actually because this was the only combination that actually works (Sorta) > the rest does not even work at all. If i switch the % with @ on: > > -value=>\%userdata > > or > > %userdata = $cgi->cookie('userdata'); > > The result are that it wont work.? The whole idea for this is a user will > enter his user id and password upon login, the code will authenticate the > combination (Not involved here) then if it passes this check it goes here > and places the userid and password in a cookie in the users browser. Now > everytime we need to check who this user is while logged in, the cookie > pulls his userid and password out of the cookie. Am i attacking this wrong > or something? That still dont explain WHY this works for aroun 80% of my > userbase and NOT for the other %20 ?
Have you tried: my $value = join '~', %userdata; # pick your own delimiter and then split it back on the receive side: my %values = split /~/, $cgi->cookie('userdata'); # sample snippet: use strict; use CGI; my $cgi = new CGI; my $cookie = $cgi->cookie(-name => 'userdata'); if ($cookie) { # if userdata cookie already set print $cgi->header(); my %values = split /~/, $cookie; print "Existing cookie values: "; foreach (keys %values) { print "<BR>$_=$values{$_}\n" }; print "<BR>\n"; } else { # cookie not set - set it my %userdata = ('userid' => 'fubar', 'password' => 'barfu', 'expires' => 'Tue, 01-Jan-2003 00:00:00 GMT'); my $value = join '~', %userdata; my $cookie = $cgi->cookie(-name => 'userdata', -value => $value, -expires => '+15m', -path => '/', -domain => '.your.net', -secure => 0); print $cgi->header(-cookie => $cookie); print "<BR>Setting new cookie\n"; } -- ,-/- __ _ _ $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-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs