#!/usr/bin/perl srand(time); $expdate = mygmtime(); $cid = int(rand(1000000)); print "Set-Cookie: NAME=$cid; expires=$expdate\n"; print "Content-type:text/html\n\n"; print <Welcome

Welcome!

Your cookie is $cid.

EndOfHTML sub mygmtime { @months = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug", "Sep","Oct","Nov","Dec"); @days = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); # (time) would be now, so we want to set it to expire sometime # later. here we expire it in 7 days. ($sec,$min,$hr,$mday,$mon,$yr,$wday,$yday,$isdst) = gmtime(time + (86400*7)); # format must be Wed, DD-Mon-YYYY HH:MM:SS GMT $timestr = sprintf("%3s, %02d-%3s-%4d %02d:%02d:%02d GMT", $days[$wday],$mday,$months[$mon],$yr+1900,$hr,$min,$sec); return $timestr; }