How to create cookie in perl

by kalai 2009-08-12 11:20:46

You can set value in cookie using CGI module in perl, you have to store the below code with .cgi extension
and when this file is called or executed the value is set of variable name 'MY_COOKIE' using $query->cookie() function

#! usrinperl

use CGI;
$query = new CGI;

$variable="value";
$cookie = $query->cookie(-name=>'MY_COOKIE',
-value=>$variable,
-expires=>'+1h',
-path=>'/');


print $query->header(-cookie=>$cookie);
$query->start_html('My cookie-set.cgi program');
print $query->h3('The cookie has been set');
$query->end_html;

Tagged in:

1391
like
0
dislike
0
mail
flag

You must LOGIN to add comments