WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The WordPress Codex clearly states that if your website is served from example.com, for the sake of performance, you can have the cookies served from www.example.com by adding this to your wp-config.php:

define('COOKIE_DOMAIN', 'www.example.com');


  • The cookies are still being served from example.com and not www.example.com. What's wrong? or does this no longer work?

PS: Edited to be precise.

share|improve this question
So well that I've searched, I could find no "exact duplicate" to this. Here's something very related and helpful (for my own reference). – its_me Jun 27 '12 at 3:45
up vote 1 down vote accepted

Looks like I mis-interpreted what's said in the codex. So, here's the thing...

This is what WordPress does by default: define('COOKIE_DOMAIN', '.example.com'); — which means, cookies are sent with all the sub-domains, including example.com itself, even if your WordPress website itself is hosted on www.example.com.

Basically the point is, when your WordPress site is served from www.example.com, you can also have the cookies sent only with www.example.com and not other sub-domains, by adding this in your wp-config.php:

define('COOKIE_DOMAIN', 'www.example.com');

So, at most, what the aforementioned code does is restrict the cookies to the sub-domain that serves your WP site.

NOTE: And just in case it's not clear -- it's pointless to use define('COOKIE_DOMAIN', 'www.example.com'); when your site itself is served from example.com or some other sub-domain, and not 'www.example.com'.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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