Closed Thread Icon

Topic awaiting preservation: safe code for cookies (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8643" title="Pages that link to Topic awaiting preservation: safe code for cookies (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: safe code for cookies <span class="small">(Page 1 of 1)</span>\

 
viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 05-09-2003 18:42

I need a safe javascript code for setting, getting and deleting a cookie.
It must work fine in IE, Mozilla, Netscape and Opera, newer versions.
I have one that's not that safe.
Anyone knows of a free code that complies to such requirements?
Thanks.

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

posted posted 05-09-2003 18:45

Cookies are pretty old stuff, any code you get should be complient with everything since NS2, could be wrong ...
This is really something google/jsresource searchable.

viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 05-09-2003 19:10

The code I have is old, as the cookies, but it doesn't set the cookie in Opera.
Here's the code, that I found in Internet some years ago, I always used it, but now I found out it doesn't set cookies for Opera and I need it to:

code:
function SetCookie (name, value)
{
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-09-2003 19:46

http://faq.ozoneasylum.com/FaqWiki/shownode.php?id=1048&sortby=rating

viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 05-09-2003 20:02

Wow, I shouldn't have asked!
Actually, I found out why my stupid Opera browser (I just hate this browser) is not working fine with that SetCookie function.
Here's what I found in a Help page of Opera about cookies:
"Web developers should note that Opera does not store cookies sent from files loaded with the "file://" protocol, e.g. local files on your hard disk. The reason is that such cookies are considered a privacy risk"
Since I'm working locally, my addresses all start with file://
Damn Opera!

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

posted posted 05-09-2003 20:25

So I was right in the end ? yay

viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 05-09-2003 21:54

It depends on the context. It was perfectly correct but not related to the problem I was trying to solve...
I tested in my localhost and it worked fine. Hours lost because Opera is finicky.

« BackwardsOnwards »

Show Forum Drop Down Menu