I want to achieve cookie free image serving as discussed here :


I have created a new sub-domain "static.example.com" serving only images, javscript and css (file serving restrictions made via filesmatch.conf file) , pls. tell how to make it serve cookie free images.



For Drupal (and probably Wordpress) this can be easily fixed by setting up $cookie_domain = 'www.example.com' value in settings.php.


You should make the cookie specific for the "dynamic" domain, e.g. instead of

Set-Cookie:  name=newvalue; expires=date; path=/; domain=.example.org

do this

Set-Cookie:  name=newvalue; expires=date; path=/; domain=www.example.org

then the client will not send the cookie to retrieve the static content.

It seems this can be done at the Apache level with mod_headers. What you probably need is to add a line to your "dynamic" domain like (not tested):

Header edit Set-Cookie domain=.example.org domain=www.example.org
  • I am using drupal and it sets the cookies, I don't want to change drupal config and simply strip cookies from my static subdomain. – iTech Mar 23 '10 at 15:04
  • Good to know. I have edited my answer. – Dan Andreatta Mar 23 '10 at 15:17
  • Thanks Dan, this seems to be the solution I am looking for - can you pls. tell the exact syntax to put into my apache "filesmatch.conf" file for "static.example.com" subdomain to get this working. Thanks – iTech Mar 23 '10 at 15:37
  • That configuration goes for the www.example.com domain, instructing the client not to send the cookie to static.example.com. It can go anywhere in the configuration, probably you want it in the main <VirtualHost> section – Dan Andreatta Mar 23 '10 at 16:03
  • Thanks a lot Dan for posting Apache solution but I found a better solution posted as answer to this query. – iTech Mar 24 '10 at 6:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.