JQuery Cookie Paths are Case Sensitive
At some point when building an application you will need some sort of state persistence, especially when using things like tabs. How you do this? Simple use cookies, if you are using jquery in your project there is a little plugin available to set them.
I am using this one, http://plugins.jquery.com/project/Cookie the links are actually broken but you can find what you need to get you started here: http://www.electrictoolbox.com/jquery-cookies/
What is the gotcha? I recommend setting the path to “/” Why? believe it or not the paths are case sensitive, this means if you don’t a path it will set it for you based on the current path.
Whys is this bad? Well say you had a path /car/create but the user typed in /Car/Create, yep you guessed it there will be two cookies if the path doesn’t match exactly then you wont get the right value back.
Some users have reported that the cookie doesn’t expire, you might want to give this a go if that happens.
$.cookie(‘cookiename’, null, { path: ‘/’, expires: -10 })
Filed under: Uncategorized | Leave a Comment
No Responses Yet to “JQuery Cookie Paths are Case Sensitive”