Click to See Complete Forum and Search --> : Cookies, directories and Javascript


doodler
05-11-2003, 09:18 AM
ok, i have a page where the user chooses a personal id and the theme for my site: http://www.psn-online.net/setup

It stores the information by cookies. This information is then retrieved in other pages using a getcookie function e.g. getcookie('lala')

The script to get the cookie as well as to set it is at http://psn-online.net/scripts/03.js

Because the cookie is set at the 'setup' folder on my site, the page in the root directory which i want to retrieve the cookie will not work OR RETURN ERRORS!?? Can somebody help me with this?

You may find these links useful:
http://www.psn-online.net/home.php = page where cookie doesnt work

http://www.psn-online.net/setup = sets the cookie

http://www.psn-online.net/setup/home.php = cookie works!?

doodler
05-11-2003, 10:16 AM
ok, i have a page where the user chooses a personal id and the theme for my site: http://www.psn-online.net/setup

It stores the information by cookies. This information is then retrieved in other pages using a getcookie function e.g. getcookie('lala')

The script to get the cookie as well as to set it is at http://psn-online.net/scripts/03.js

Because the cookie is set at the 'setup' folder on my site, the page in the root directory which i want to retrieve the cookie will not work OR RETURN ERRORS!?? Can somebody help me with this?

You may find these links useful:
http://www.psn-online.net/home.php = page where cookie doesnt work

http://www.psn-online.net/setup = sets the cookie

http://www.psn-online.net/setup/home.php = cookie works!?

doodler
05-11-2003, 10:30 AM
<!--
var Today = new Date();

function getexpirydate( nodays){
var UTCstring;
Today = new Date();
nomilli=Date.parse(Today);
Today.setTime(nomilli+nodays*24*60*60*1000);
UTCstring = Today.toUTCString();
return UTCstring;
}
function getcookie(cookiename) {
var cookiestring=""+document.cookie;
var index1=cookiestring.indexOf(cookiename);
if (index1==-1 || cookiename=="") return "";
var index2=cookiestring.indexOf(';',index1);
if (index2==-1) index2=cookiestring.length;
return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
function setcookie(name,value,duration){
cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
document.cookie=cookiestring;
}


function deleter(cookiename){
setcookie(cookiename, "", "-100")
}

//-->

is what im using it works in both netscape and IE u see.

doodler
05-11-2003, 10:36 AM
I read in a thread somewhere that you have a debugger (MS Script degugger or something similar). Could you tell me which? It would help me alot. Thanx.

doodler
05-11-2003, 10:43 AM
Originally posted by Dave Clark
Using the function I posted, you would do it as follows:

setCookie("cookieName", cookieValue, expDateObject, "/");

That last argument is the kicker.

Dave

Sorry I don't understand. So what would be the complete code to get and set the cookie?
P.S i think i have that debugger!

doodler
05-11-2003, 10:50 AM
setcookie('mycookie', 'myvalue', 365);
=
setcookie(name, value, duration)

doodler
05-11-2003, 10:55 AM
i take it that this script is cross-browser compatible?

doodler
05-11-2003, 10:57 AM
Thanks a lot.

doodler
05-11-2003, 11:27 AM
Its not working!

setCookie(cookieName, cookieValue, expDate, "/"); = this isnt right, its not in the script!!!!! I'm totally confused now.

doodler
05-11-2003, 01:35 PM
the whole thing didnt work because i didnt know how to use the function and the stuff u sed wasnt in the script like path and domain

doodler
05-11-2003, 01:46 PM
i dont have the script. can u post it again with all the amendments.