// function for reading individual cookie values function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "=") if (c_start!=-1) { c_start=c_start + c_name.length+1 c_end=document.cookie.indexOf(";",c_start) if (c_end==-1) c_end=document.cookie.length return unescape(document.cookie.substring(c_start,c_end)) } } return null } // The function that alerts me of what I have function alertMe() { alert ("EXISTING COOKIES: Visit Flag is: "+getCookie("visit_flag")+" The user came from: "+getCookie("bis_referrer")+" and the entry point was: "+getCookie("bis_entry")+" Valid Until: "+lifeTime); } //-------------------the work begins---------------- // Check to see if we have an existing cookie and flag, and a referrer that is not empty function trackMe() { if ((document.cookie != "")&&(getCookie("visit_flag")>=1)&&(getCookie("bis_referrer")!="")) { var visit_flag = getCookie("visit_flag"); var bis_referrer = getCookie("bis_referrer"); var bis_entry = getCookie("bis_entry"); // now lets increase the visit_flag and re-bake the cookies with updated dough where necessary visit_flag = visit_flag++; // set the current juncture in the lifeTime variable var lifeTime = new Date(); // set expiry time of the cookie x milliseconds ahead lifeTime.setTime(lifeTime.getTime() + (2*60*60*1000)); // lets bake several small cookies // document.cookie = "visit_flag="+visit_flag+";expires="+lifeTime.toGMTString()+";domain=lincolnco.com"; // document.cookie = "bis_referrer="+bis_referrer+";expires="+lifeTime.toGMTString()+";domain=lincolnco.com"; // document.cookie = "bis_entry="+bis_entry+";expires="+lifeTime.toGMTString()+";domain=lincolnco.com"; } else { // For agents with 0 flag, or an empty referrer, write a brand new cookie without caring what the previous values // scour the user agent for referrer, and entry point and then store escaped values to prevent conflict var visit_flag = 1; var bis_referrer = escape(document.referrer); var bis_entry = escape(self.location); var lifeTime = new Date(); // set expiry time of the cookie x milliseconds ahead lifeTime.setTime(lifeTime.getTime() + (2*60*60*1000)); // lets bake several small cookies document.cookie = "visit_flag="+visit_flag+";expires="+lifeTime.toGMTString()+";domain=lincolnco.com"; document.cookie = "bis_referrer="+bis_referrer+";expires="+lifeTime.toGMTString()+";domain=lincolnco.com"; document.cookie = "bis_entry="+bis_entry+";expires="+lifeTime.toGMTString()+";domain=lincolnco.com"; } //document.write ("Visit Flag is: "+getCookie("visit_flag")+"
The user came from: "+getCookie("bis_referrer")+"
Entry point was: "+getCookie("bis_entry")+"
Valid Until: "+lifeTime); } //Developed by Donny - www.idonny.com // Feel free to use this code whichever way you want, and if you feel like, give me some publicity by pointing to my portfolio for more code