Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Jason Carlton
November 29, 2009, 1:55 am
rate this thread
For CGI::Cookie, Cpan states:
The simplest way to send a cookie to the browser is by calling the bake
If you want to set the cookie yourself, Within a CGI script you can
send a cookie to the browser by creating one or more Set-Cookie:
fields in the HTTP header. Here is a typical sequence:
my $c = new CGI::Cookie(-name => 'foo',
-value => ['bar','baz'],
-expires => '+3M');
print "Set-Cookie: $c\n";
print "Content-Type: text/html\n\n";
When should I use "bake", and when should I simply use "Set-Cookie"?
Is there an advantage or disadvantage either way?
The script I'm building doesn't actually print anything to the screen,
but just redirects to a success page. Since there's no content-type
being printed, does this mean that I need to use bake?
Re: Using CGI::Cookie
This is an excellently formatted question! But a peek at the source
will probably answer the question easily for you:
It looks like one may want to use bake for a couple different reasons.
Possibly for consiseness in the client code, or where the code may be
used in different environments (CGI and mod_perl in particular).