Cookies

They have: 13 posts

Joined: Mar 2000

Someone in the CGI forum told me that you can use Javascript to send and recieve cookies....now if that is true, I would really appreciate some help on this, as the only way I know of doing it is with CGI/Perl and I know sh-it all about perl.

thanks anyone,
Chris.

------------------
This has been a Loss4Words production. Thank you for tuning in.

This has been a Loss4Words production. Thank you for tuning in.

They have: 141 posts

Joined: Aug 1999

// Use this function to retrieve a cookie.
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
}
}
return null;
}

// An adaptation of Dorcht's function for setting a cookie.
function setCookie(name, value, expires, path, domain, secure) {
document.cookie = name + "=" + escape(value) +
((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
((path == null) ? "" : "; path=" + path) +
((domain == null) ? "" : "; domain=" + domain) +
((secure == null) ? "" : "; secure");
}

Hope this helps, to delete a cookie, set the time to a time that is before the time that it is set.

------------------
Visit the dLo.Network
http://dlo.net

They have: 13 posts

Joined: Mar 2000

Thanks...now can you explain how I could put that into practise...I wouldn't normally ask but it's 2am, I'm bored and I don't understand it. I mean, I do, but not enough to be able to use it, you know?

Like, how do I refer to or use the information stored in the cookie once it has been retrieved?

------------------
This has been a Loss4Words production. Thank you for tuning in.

This has been a Loss4Words production. Thank you for tuning in.

They have: 13 posts

Joined: Mar 2000

Ummm....never mind...some swift debugging fixed it all up, after i figured out what was going on.... thanks mister

------------------
This has been a Loss4Words production. Thank you for tuning in.

This has been a Loss4Words production. Thank you for tuning in.

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.