function getname(){ //this is the name of the function var thiscookie=document.cookie; //this retrieves the cookie var location=thiscookie.indexOf("surfername="); //this is the location of where the information starts var endlocation=thiscookie.indexOf(":"); //this is the location of the end of the information if (location != -1){ //this checks to see if the cookie exists var begin=location+11; //this gets the location of the begining of the surfer's name var yourname=thiscookie.substring(begin, endlocation); //this grabs the value from the cookie yourname = unescape(yourname); //this unencodes the surfer's name return yourname; //this returns the surfer's name } else{ var yourname = prompt("Welcome, please enter in your name.",''); //this asks for the name document.cookie = "surfername=" + escape(yourname)+":" + "expires=Fri Dec 10 11:00:00 PST 2009 http://opa-ma.blogspot.com"; // the above line sets the cookie with a name=value pair of surfername=value // you may modify the expiration date by changing the expires= } return yourname; //this returns the surfer's name }