Last updated on November 18th, 2015 at 03:37 am

Below is the valid parameters that can be used when a cookie is being called using perl script, Below you will find how to use perl cookie with example.

a partial or complete domain name for which the cookie is valid. Like ‘’ for the entire domain (,, etc.), or ‘’ to refer to one server.

(optional) The expiration date for this cookie.
+60s 60 seconds from now
+20m 20 minutes from now
+5h 5 hours from now
+1d 1 day from now
-3d 3 days ago
now immediately
+6M 6 months from now
+1y 1 year from now
Monday, 28-Dec-98 12:30:00 GMT expire at this specific date & time

the name of the cookie (req’d)

(optional) If you specify this attribute, the browser will check it against your script’s URL before returning the cookie.
The default is set to ‘/’.

(optional) The cookie will only be sent if the CGI request is occurring on a secure channel.

(req’d) The value of your cookie. This can be a scalar value, array reference, or hash reference.


use CGI;
$query = new CGI;
$cookie = $query->cookie(-name=>'MY_COOKIE_TEST',

Leave a Reply

Your email address will not be published. Required fields are marked *