Index: wp-includes/default-constants.php
===================================================================
--- wp-includes/default-constants.php	(revision 25015)
+++ wp-includes/default-constants.php	(working copy)
@@ -226,8 +226,14 @@
 	/**
 	 * @since 2.0.0
 	 */
-	if ( !defined('COOKIE_DOMAIN') )
-		define('COOKIE_DOMAIN', false);
+	if ( ! defined( 'COOKIE_DOMAIN' ) ) {
+		$cookie_domain = false;
+		$home_host = parse_url( home_url(), PHP_URL_HOST );
+		$site_host = parse_url( site_url(), PHP_URL_HOST );
+		if ( $home_host !== $site_host && str_replace( 'www.', '', $home_host ) === str_replace( 'www.', '', $site_host ) )
+			$cookie_domain = str_replace( 'www.', '', $site_host );
+		define( 'COOKIE_DOMAIN', $cookie_domain );
+	}
 }
 
 /**
