#!/usr/bin/perl $cookie = $ENV{'HTTP_COOKIE'}; if ($cookie) { if ($cookie =~ /count=([^;]*)/) {$count = $1;} } if ($count) { $count++; } else { $count = 1; } print "Content-type: text/html\n"; print "Set-Cookie: count=$count; path=/; domain=SERVER\n\n"; print "<html>\n"; print "<head>\n"; print "<title>Cookie Counter</title>\n"; print "</head>\n"; print "<body bgcolor=ffffff>\n"; print "You have visited $count time(s).<br>\n"; print "</body>\n"; print "</html>\n"; exit;
You can then look at the page at http://SERVER/cgi-bin/cookie.cgi where SERVER is your computers hostname. Repeatedly pressing the Reload button should give you a different number each time. If the number is constantly 1 then there are two likely possibilities. Either you did not change the word SERVER to your server's hostname or the browser is not accepting cookies.