SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2011
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is document.cookie still cool?

    Hello,

    I'd like to know if document.cookie is still considered a good way to set cookies.

    Cheers.


  2. #2
    SitePoint Addict dnordstrom's Avatar
    Join Date
    Jul 2006
    Location
    Amsterdam
    Posts
    337
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    I am by no means an expert on cookie management in JavaScript. However, I did make a Google search for "document.cookie 2011" (without quotation marks), a search phrase which should give insight into if it's still a legit way to handle cookies. For example, the discussion board Stack Overflow has many posts which should appear, in which professional developers tend to (almost always) give hints to bad practice of posted code. By searching for 2011 as well, you get recent posts.

    Results lead me to links such as this one, which suggests it is indeed legit. If this was a bad practice, posters would generally say so.

    Perhaps more interesting, I also found this recent blog post which is a good read. I have yet to read all of it, but it discusses security issues related to the subject.
    Daniel Nordstrom. of. Nintera(ctive)
    -- Featured post: Part 2. Writing NI.JS JavaScript
    ----- Follow me on Twitter. Got project? Contact me.
    -------- SitePoint: Community Guidelines Be A Great Member

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,712
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    A while ago Quirksmode performed a good study of handling cookies across different web browsers, resulting in the some useful functions to manage them.
    Cleaned up versions of those functions can be found at the cookie handling functions page.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2011
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So you would definitely say that it's ok to manage cookies with javascript?

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,712
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by rhgiant View Post
    So you would definitely say that it's ok to manage cookies with javascript?
    Yes indeed, given that you're mindful of situations where someone not having scripting enabled might interfere with things.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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