How to remove a cookie in Apache

Viewed 47671

I need to remove a cookie from the HTTP request that gets to the server. Doing it on the client (that writes this cookie) or on the server (that reads it) is not an option. I have Apache 2.0 that proxies requests between client and the server, so I was hoping to remove the cookie right there in Apache using mod_rewrite.

My question is, is there a way to remove a certain cookie from the HTTP request using mod_rewrite?

If not possible to remove just one cookie then as a last resort to remove all cookies from the request?

I am open to other suggestions of how to accomplish this if mod_rewrite is not the right tool for this task.

4 Answers

With Apache > 2.2.4, you could have used :

RequestHeader edit Cookie "^(.*?)ANY_COOKIE=.*?;(.*)$" $1$2

I use this to unset all cookies (good to serve static content)

Header unset Cookie
Header unset Set-Cookie
Related