use strict; use CGI qw(:standard); $q = new CGI; # Create a 11 character random string as a # session id. (Yes, it's swiped from the perl cookbook:-) @chars = ( "A" .. "Z", "a" .. "z", 0 .. 9 ); $usersession = join("", @chars[ map { rand @chars } (1 .. 11) ]); # Set a cookie that expires when # the user closes their browser $initcookie = $q->cookie( -name=>'User_Session', -value=>$usersession, -expires=>'', # leave this blank -path=>'/', -domain=>'www.somewebsite.com', -secure=>0 ); print $q->header(-cookie=>$initcookie);