Click to See Complete Forum and Search --> : how to read cookies


derksj
08-12-2003, 10:19 AM
I have this php script that set a cookie

naam
nameofperson
www.vakantiehuizengids.com/
1024
1774618752
29581538
2354136048
29581537
*
telefoon
03587687686+%28avond%29
www.vakantiehuizengids.com/
1024
1774618752
29581538
2354136048
29581537
*
etc....

now i want to show the variables into a page

like this

name = nameofperson
telefoon = 035907709+%28avond%29

etc etc ....
is there someone who can tell me how to do that

Khalid Ali
08-12-2003, 10:31 AM
you can access a cookie in php using something along these lines.

echo "$HTTP_COOKIE_VARS[cookiename]";

where cookie name is the name that you used when you set the cookie.

derksj
08-12-2003, 10:34 AM
sorry

but i have to read the cookie with javascript

Khalid Ali
08-12-2003, 10:39 AM
for tht take a look at he lin below.its the most basic solution to read and write cookies with JavaScript.

http://68.145.35.86/skills/javascripts/SimpleLoginCookieScript.html

derksj
08-12-2003, 10:42 AM
so i use this function

function getCookie (CookieName) {
var cname = CookieName + "=";
var i = 0;
while (i < document.cookie.length) {
var j = i + cname.length;
if (document.cookie.substring(i, j) == cname){
var leng = document.cookie.indexOf (";", j);
if (leng == -1) {
leng = document.cookie.length;
}
return (unescape(document.cookie.substring(j, leng))).split("`");
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
}

what should i code to schow my variables

Fang
08-12-2003, 10:44 AM
derksj don't give real data; I know the persons name and address!