DISQUS

The Puerto Rican Rails Dude: Quick and Dirty Browser Cookie Testing

  • Eric · 1 year ago
    Appreciate the link, but if you'd read my article, you'd have seen that my method does not in fact use a GET parameter. The first thing I found in google did, but I also ditched that, not because it wasn't clean (which it isn't) but because of other bugs it introduces, which I also mentioned in my article.

    That said, I like your solution even more, since while it does run on each page load, the impact should be negligible, and it doesn't require a page redirect at all. Nice work. :)

    -Eric
  • Dan Gebhardt · 11 months ago
    Thanks for your code, Dennis. It works well to detect if cookies can be accepted by browsers, but does not necessarily detect if Safari's "Private Browsing" mode has been enabled. In this mode, new cookies can apparently be created but cookies created outside of "Private Browsing" mode will not be overwritten. This can create almost as many problems for cookie-based sessions as if cookies were not accepted at all.

    I've modified your solution to also test for this case. In order to do this, I set the test cookie to a dynamic value, such as the current time. I then check whether the cookie has been set to the dynamic cookie value to ensure that "private browsing" has not been enabled.

    In order for this to work, you unfortunately can't delete the cookie after the test. Otherwise, the test won't recognize when the user had a previous session created outside of private browsing mode that they are now trying to change in private browsing mode.

    NOTE: I tried to post this comment earlier with a bit of javascript source in my comments, but DISQUS wasn't happy so I trimmed my code out.
  • Upcoming fishing events · 8 months ago
    you are on my rss reader now