A Personal Counter

To create your own personal visit counter, copy the cookie function script from the functions page and paste it in the <HEAD>...</HEAD> portion of your HTML document. Once you do that, you can embed a script that employs the universal cookie functions in your document. Take a look at the following script:

<SCRIPT>

function getCookie(name) {
     var prefix = name + "=";
     var begin = document.cookie.indexOf(prefix);

     if (begin == -1) return null;

     var end = document.cookie.indexOf(";", begin);

     if (end == -1) end = document.cookie.length;

     return unescape(document.cookie.substring(begin + prefix.length, end));
}

function setCookie(name, value, expires, path, domain, secure) {
     document.cookie = name + "=" + escape(value) +
                                    ((expires) ? "; expires=" + expires.toGMTString() : "") +
                                    ((path) ? "; path=" + path : "") +
                                    ((domain) ? "; domain=" + domain : "") +
                                    ((secure) ? "; secure" : "");
}

</SCRIPT>

etc...

<SCRIPT>

var visits = getCookie("counter");

document.write("<FONT COLOR=\"#cc0000\">");

if (visits) {
     visits = parseInt(visits) + 1;

     document.write("By the way, you have been here ");
     document.
write('<IMG SRC="odometer/' + visits + '.gif">');
     document.
write(' times.');
}
else {
     visits = 1;

     document.write("By the way, this is your first time here.");
}

document.write("</FONT>");
document.
write("Reload the page to see that the counter has incremented.");

setCookie("counter", visits);

</SCRIPT>

NOTE that this script can be placed anywhere on the page. It prints the number of times the user has visited your site.