November 2001
Beginner
320 pages
5h 53m
English
In Perl the CGI::Cookie module will create a cookie HTTP header for you by supplying the cookie data, domain, and expiry date to a new cookie object. For example
my $query = new CGI;
my $cookietext = $query->cookie(-name => 'sample',
-value => { login =>
$login,
other =>
'Other'
-path => '/',
-domain =>
'mcwords.mchome.com',
-expires => '+1y');
print "Set-Cookie: $cookietext\n";
In Python there is a third party module called Cookie which will build a new cookie for you. For example, we could rewrite the above using the Cookie module like this:
import Cookie cookie = Cookie.SmartCookie() cookie['sample'] = 'login=%s; other=Other' % (login) cookie['sample']['path'] = '/' cookie['sample']['domain'] = 'mcwords.mchome.com' cookie['sample']['expires'] ...