When this page finished loading in your browser you should see an alert pop up with "Welcome" in it. At least that is what you should see the first time that you visit this page. If you have visited the page before during your current browser session then you will not see that alert.
That alert is just an example. The purpose of this script is to determine whether this is the first time that a web page has been accessed in this browser on this computer and if it is to perform a given piece of processing (in the example on this page it calls the alert with the welcome message).
How the script works is that it tests for the existance of a particular cookie and then checking if that cookie contains text that matches the filename of the current page (without the extension). If the appropriate cookie exists and has that content then the script assumes that you have visited the page before.
Because the script uses session cookies nothing is actually written to your visitor's computer and the cookie will be automatically removed when they close their browser.
The final step is to replace the alert('welcome'); statement with whatever processing it is that you want to have performed only on the first visit to the page.
This article written by Stephen Chapman, Felgall Pty Ltd.