Disable Cookies using .htaccess file

Here I comes with the quick tip, this is small tip but very effective. This is about disabling the Cookies on site.

You might be suprised that, Why someone would like to disble the cookies on the website? I would say that is the proper question, but sometimes it would be good to disable the cookies especially for the Cookie Free Domain.

Cookie Free Domain?

Cookie Free Domain is just like simple domain or sub domain which are used to serve the static contents and which have no one cookies are set. So when we have separate domain for the serving the static content the it will increase the performance of the website by loading the content in parallel. But what is the relation with the disabling the cookies? You can find this relation in benefit section of this article.

Disable Cookies using .htaccess

Here are the simple just two lines to disable cookies on domain using Htaccess file.

Header unset Cookie Header unset Set-Cookie
  Header unset Cookie
  Header unset Set-Cookie

Benefit

When browser makes any request to the server then it will send all cookies in header with all request. So let’s assume if you have 1 KB of cookies set and you are making 100 requests to the server then that 1 KB will sent to server 100 times and server also send that back to browser aswell.

So I hope you are now clear with the concept/relation of the Cookie Free Domain and disabling the cookies with .htaccess file.

If you want to create a cookie free subdomain for wordpress then you will like this article for sure.

So I keep this topic open over here. You can ask questions by comments if you have any.

Also don’t forget to Subscribe to our feed, Like us on Facebook and Follow us on Twiiter to get updates for the new posts/article.

Share This Article

  • Yuri Taillandier

    Excellent hint ! It saves you from spending extra cash on an additional domain to serve static content.

    Just set up a cdn.yourdomain.com subdomain and put these directives into the htaccess file and voila – you have your own static, cookieless domain.

  • Chris

    Anyone know how to do cookie-free domains on joomla? I been trying to
    test my site with yslow and got suggestion to do that. There is option
    in joomla global configuration – Site Settings – Cookie setting – cookie
    domain and cookie path but I tried a lot of options that I found online
    but I guess I don’t know how to do it properly.

    I created subdomain but the same thing, I copied static elements like
    images to that domain and linked through css but nothing happens.

    after that I tried not to create new folder when I was creating new
    subdomain but link subdomain in same folder where main domain is, but
    nothing happens.

    Any ideas? Thanks