Menu

#16 setCookie() with more parameters

open
nobody
None
5
2005-09-06
2005-09-05
mosh
No

Wouldn't it be possible to add some more features to
the setCookie() function in /src/util/cookie.js? in my
apps i'm using a function like this:

this.setCookie = function(cookie_name, cookie_value,
cookie_lifetime, cookie_path, cookie_domain, is_secure) {
if (!cookie_name) {
return false;
}

document.cookie = escape(cookie_name) + '=' +
escape(cookie_value) + (cookie_lifetime ? ';expires=' +
(new Date((new Date()).getTime() + (1000 *
cookie_lifetime))).toGMTString() : '' ) + (cookie_path
? ';cookie_path=' + cookie_path : '') + (cookie_domain
? ';cookie_domain=' + cookie_domain : '') + (is_secure
? ';secure' : '');

if (cookie_lifetime < 0) {
if (typeof this.getCookie(cookie_name) ==
'string') {
return false;
}
return true;
}

if (typeof this.getCookie(cookie_name) ==
'string') {
return true;
}
return false;
}

Discussion

  • Doug Melvin

    Doug Melvin - 2005-09-06

    Logged In: YES
    user_id=184788

    This is _not_ a bug.

    Please use the BUG tracker to report BUGS.

    Thank you.

    <!-- CLOSE ME -->

     
  • - 2005-09-06

    Logged In: YES
    user_id=706287

    It's a feature request. Sorry, I thought it was submitted
    as a Feature Request. Well, the "Group" was Feature Request
    but the "Data Type" field was set to Bugs. I've changed the
    type. Please use Bugs for something broken, and Feature
    Requests for something new. Don't forget to double check
    all those boxes and such. :)

     
  • - 2005-09-06
    • labels: 541438 -->
    • milestone: 101472 -->
     
  • Doug Melvin

    Doug Melvin - 2005-09-06

    Logged In: YES
    user_id=184788

    Okay. I am cool with this. However, if we ARE going to add
    an enhanced setCookie, them we might as well add an enhanced
    deleteCookie, getCookie and maybe cloneCookie ect ect.

    Also: I would like to see setCookie, as complex as it is,
    still be able to be used in "simple mode" I.e
    setCookie("login=1") or whatever.

    also I would imagion deleteCookie taking whildcards and such :-P

    Alos: as always we will want to ensure that any new cookie
    manager be cross-browser (and tested as such)

    cheers

     

Log in to post a comment.