#!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; use CGI::Cookie; use CGI::Carp qw/fatalsToBrowser/; my $c = CGI::Cookie->new( -name => 'mycookie', -value => ['foo','bar'], -secure => 1, -expires => '+3M', -domain => 'your domain', -path => '/path/to/cgi-bin -httponly => 1, ); print "Set-Cookie: $c\n"; print "Content-Type: text/html\n\n";