View Full Version : Permission to use "Welcome" cookie code

Duffy Yuw
03-19-2009, 06:18 AM
Will the author of this "Welcome back" message - javascript cookie code below, let me know whether it is permissible to use this code without any further permission. The website mentions that it can also be customised? I'm hoping to use this in a college assignment and need to clarify any copyright permissions.


var lastvisit=new Object()
lastvisit.firstvisitmsg="This is your first visit to this page. Welcome!" //Change first visit message here
lastvisit.subsequentvisitmsg="Welcome back! Your last visit was on <b>[displaydate]</b>" //Change subsequent visit message here

lastvisit.getCookie=function(Name){ //get cookie value
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""

lastvisit.setCookie=function(name, value, days){ //set cookei value
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";

if (lastvisit.getCookie("visitcounter")==""){ //if first visit
lastvisit.setCookie("visitcounter", 2, 730) //set "visitcounter" to 2 and for 730 days (2 years)
document.write(lastvisit.subsequentvisitmsg.replace("\[displaydate\]", new Date().toLocaleString()))


Many thanks
Duffy Yuw