MS Personal Web Server & cookies
Hi
I'm trying to get some client-side JavaScript to use cookies and I'm having trouble. I'm using code from irt.org
function Get_Cookie(name) {
var start = document.cookie.indexOf(name + '=');
var len = start + name.length + 1;
if ((!start) && (name != document.cookie.substring(0,name.length)))
return null;
if (start == -1)
return null;
var end = document.cookie.indexOf(';',len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len,end));
}
function Set_Cookie(name,value,expires,path,domain,secure) {
document.cookie =
name + '=' + escape(value) +
( (expires) ? ';expires=' + expires.toGMTString() : '') +
( (path) ? ';path=' + path : '') +
( (domain) ? ';domain=' + domain : '') +
( (secure) ? ';secure' : '');
}
I'm guessing that it's probably something to do with the fact I'm using Personal Web Server, and domain names. I'm using a domain of 'newdpr.com', and the directory on my machine is wwwroot/newdpr. Is this something that I have to wait until I upload the site onto a full server? Newdpr is just a working name.
Thanks!
Peter
Touchup image processing applet
Pixel Development Web Design, Photography
pmj7 posted this at 19:18 — 2nd February 2005.
He has: 234 posts
Joined: Nov 2002
Found the solution - set the domain parameter to blank and the cookie routines simply apply to whatever domain the current window belongs.
Peter
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.