<!--This script makes use of a cookie to get and set the number of page visits -->

<html>
<head>
<title>Basic Cookie Example</title>
<script language="JavaScript">
function getCounterVal() {
var cookie = document.cookie;
var start = cookie.indexOf("mycounter");
var d = new Date();
d.setTime(d.getTime()+7*24*60*60*1000); // Set date a week ahead
if (start == -1) {
document.cookie="mycounter=1; expires=" + d.toGMTString();
return 1;
}
eval(cookie.substring(start));
mycounter++;
document.cookie = "mycounter=" + mycounter + "; expires=" + d.toGMTString();
return mycounter;
}
</script>

</head>
<body>
<script language="JavaScript">
document.write("You have visited this page " + getCounterVal() + " times");
</script>

</body>
</html>