JQuery Cookie Paths are Case Sensitive

17Oct10

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 })

Advertisements


No Responses Yet to “JQuery Cookie Paths are Case Sensitive”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: