Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to prevent browser from sending a specific cookie?

I'm storing some preference data in cookies. However, I just noticed that this data gets sent to the server with every request. Is there a way to prevent that from happening?

A friend tipped off web storage, but this still leaves IE6/7 without a solution.

like image 552
randomguy Avatar asked Sep 17 '25 10:09

randomguy


1 Answers

You can set cookies to be HTTP Only (so supporting browsers won't let JS access them), but not the other way around.

Web storage is the ideal solution, but you'll need to fallback to cookies for legacy browsers.

You can reduce the number of requests that include the cookies by moving some content (images, css and stylesheets in particular) to a different hostname, and limit the cookies to your primary host name.

like image 73
Quentin Avatar answered Sep 20 '25 01:09

Quentin