Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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');

Problem:

  • 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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.