#!/usr/bin/perl srand(time); $expdate = mygmtime(time+(86400*7)); $exp2 = mygmtime(time+(86400*2)); $cid = int(rand(1000000)); print "Set-Cookie: NAME=$cid; path=/class; expires=$expdate; domain=.cgi101.com\n"; print "Set-Cookie: CTEST=4; path=/class; expires=$exp2; domain=.cgi101.com\n"; print "Set-Cookie: fnord=23; path=/class; expires=$expdate; domain=.cgi101.com\n"; print "Content-type:text/html\n\n"; print <Welcome

Welcome!

Your cookie is $cid.

EndOfHTML sub mygmtime { ($etime) = @_; @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($etime); # 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; }