function Cookie(id, value, days) { var expiration = new Date(); expiration.setTime(expiration.getTime() + (days*86400000)); document.cookie = id + "=" + value + "; expires=" + expiration.toGMTString() + "; path=/; domain=nj.com"; } //IMPORTANT - You must change the domain value above to be nj.com // from advance.net before publishing. var allcookies = document.cookie; // Check for this exact cookie // in case there are more than one on this page var id = "REMNANT"; var start = allcookies.indexOf(id + "="); // if cookie exists substring the number of user visits from the value string if (start != -1) { start += id.length +1; var end = allcookies.indexOf(";", start); if (end == -1) end = allcookies.length; var page_views = allcookies.substring(start, end); page_views = unescape(page_views); } // increase number of user visits by one if (page_views >= 1) { page_views++; } else { // or set page view to one page_views = 1; } // set or update cookie var work = new Cookie("REMNANT", page_views, 1);