i’ve a php page with a form in which i have a checkbox that user can check to select to remember field in browser next login. i’m using that code:
if(rememberCheck.checked==true){
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var cod_value=escape(codice.value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie="cod=" + cod_value+";log="+login.value;
}
function getCookie(c_name){
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++){
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name){
return unescape(y);
}
}
}
function checkCookie(){
var cod=getCookie("cod");
var username = getCookie("login");
if (username!=null && username!="" && cod!=null && cod!=""){
var usn = document.getElementsByName('usn')[0];
var codice = document.getElementsByName('codice')[0];
usn.value=username;
codice.value=cod;
}
}
The problem is that when i read cookie, it read PHPSESSID=XXXXXX, and not what i write. What can i do? can you help me?
1 Answer