It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

cookies on java script problems

cookies on java script problems

Postby purplemonster on Sun May 24, 2009 3:17 pm

here is the code.

// JavaScript Document
function checkCookie(){
setCookie(true);
if (document.cookie==null||document.cookie==""){
setCookie(true);
return "visitor";
}
if (getCookie("/login/")=="no") return "visitor";
return getCookie("/username/");
}

function setCookie(newuser){
var expire_date = new Date();
expire_date.setDate(expire_date.getDate()+1);
if (newuser) document.cookie = "mycookie=name; login=no; username=ben; expires=" + expire_date.toGMTString();
}

function getCookie(field){
var str = "";
for (var i=document.cookie.search(field)+field.length-1 ;
i<document.cookie.length ;
i++){
if (document.cookie[i]==";")
break;
str += document.cookie[i];
}
return str;
}

can't make it work and fing the regular expresions /login/ in the cookie and also /username/
why is that? someone can make it work?
thanks
purplemonster
 
Posts: 24
Joined: Fri Jul 04, 2008 9:01 pm

Who is online

Users browsing this forum: No registered users and 4 guests