"" <> writes:
> Here's the piece of code that does the cookie writing:
>
> print "Set-Cookie: ";
> print ($name1, "=", $value1, "; expires=", $expiration, "; path=",
> $path, "; domain=", $domain, "; ", $secure, "\n");
>
> print "Content-type: text/html\n\n";
Ick.
#!/usr/bin/perl
use warnings;
use strict;
use CGI qw/:standard/;
use CGI::Cookie;
my $cookie = new CGI::Cookie(-name => $name1,
-value => $value1,
-expires => $expiration,
-path => $path,
-domain => $domain,
-secure => $secure);
print header(-cookie => $cookie);
__END__
> However, if I try inserting $name2/$value2, separated from the first
> value with a semi-colon, it just doesn't store it ... I even tried just
> using plain text values to test it (ie. n=testvalue), but still nothing
> ... The first name/value is stored perfectly.
Your problem here is not with Perl; it's with your misunderstanding
about how cookies work. There's nothing wrong with that, but learning
how to partition your problems properly will aid you in finding
answers to your questions about it. In this case, you might try
posting your question to comp.infosystems.
www.authoring.cgi, as they
will have more people who know more about that sort of thing.
> Any ideas appreciated ... I would like to use the same code, rather
> than a module, simply because of lack of overhead,
Once you've decided to use Perl, you have already used enough overhead
that the additional use of a module is nearly irrelevant, and they
will save you from all sorts of problems you haven't even considered
yet, such as escaping special characters in your cookie's name or
value. It's really worth it.
> although I'm sure
> there are a number of modules out there ... I'm really more interested
> in why I can't get the code above to work with multiple values.
Cookies don't work that way, but that's not Perl's fault; you need to
learn more about how cookies operate.
-=Eric