www.webdeveloper.com
Results 1 to 3 of 3

Thread: JS Cookies

  1. #1
    Join Date
    Apr 2009
    Posts
    11

    JS Cookies

    hello,

    two question about cookies :

    1. I'm learning about JS cookies from the W3 site
    http://www.w3schools.com/JS/js_cookies.asp

    In the example they told to assign the toUTCString() method
    to the date object, I guess its because the cookie object
    can get only strings.

    But when i tried to assign the 'document.cookie' a regular
    date object, 'Without using toUTCString()', everything was
    worked prefectly.

    So, Do i have to convet the dat object to string?
    (maybe its a browser compatible issue)

    2. Why the script above (from w3) didn't work
    in some browsers at my computer (it worked perfectly when
    i upload it to some server in all browsers)?
    In my computer, It didnt works in chrome and in opera.

    Thanks for your answers

  2. #2
    Join Date
    Feb 2011
    Posts
    231
    Hy,
    The value of document.cookie property must be a string, in the following format:
    document.cookie = "name=value";
    - You can’t have spaces, commas, or semicolons inside the string.
    See also JavaScript cookies, it has more explanations and a nice example (which works)
    Last edited by MarPlo; 05-11-2011 at 10:44 AM.

  3. #3
    Join Date
    Apr 2009
    Posts
    11
    Quote Originally Posted by MarPlo View Post
    Hy,
    The value of document.cookie property must be a string, in the following format:
    document.cookie = "name=value";
    - You canít have spaces, commas, or semicolons inside the string.
    See also JavaScript cookies, it has more explanations and a nice example (which works)
    Thanks

    That what i'm asking - If the value must be a string, So why
    everything is fine when i assign an object type in the cookiie property?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles