This script will show you how to set cookie and get the value of the cookie using perl script or cgi script
Here is our setcookie.cgi script
#!/bin/perl use CGI; $query = new CGI; $cookie = $query->cookie(-name=>'managercheck', -value=>'manager', -expires=>'+4h', -path=>'/'); print $query->header(-cookie=>$cookie); print $query->start_html('My cookie-set.cgi program'); print $query->h3('The cookie has been set'); print $query->end_html;
Here is our getcookie.cgi script
#!/bin/perl use CGI; $query = new CGI; print $query->header(); print $query->start_html('My cookie-get.cgi program'); print $query->h3('The cookie is ...'); $theCookie = $query->cookie('managercheck'); print " \n"; print $theCookie; print " \n"; print $query->end_html;