Okay here is the solution:
// Begin WordPress Cookie Handling require_once("blog/wp-includes/pluggable-functions.php");
$siteurl = "http://www.fantasyblitz.com";
$blogurl = "http://www.fantasyblitz.com/blog";
$cookiehash = md5($blogurl);
define('COOKIEHASH', $cookiehash);
define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH);
define('PASS_COOKIE', 'wordpresspass_'. COOKIEHASH);
define('COOKIE_DOMAIN', false);
wp_setcookie($user_username, $login_password, false, $siteurl, $siteurl, $remember);
// End WordPress Cookie Handling
Firefox is great for troubleshooting problems with your cookies. Just login to WordPress the regular way, and then compare that cookie to the one you are trying to create outside of WordPress.
As it usually happens… after 5 months somebody will find this thread and will desperately asking you: where to put this code? 🙂
Okay here are some adjustments to the code…there was a bug with destroying the cookie when logging out.
You put this code immediately after you check authentication on your main site (in this case http://www.fantasyblitz.com/login/):
// Begin WordPress Cookie Handling require_once("blog/wp-includes/pluggable-functions.php");
$blogurl = "http://www.fantasyblitz.com/blog";
$cookiehash = md5($blogurl);
define('COOKIEHASH', $cookiehash);
define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH);
define('PASS_COOKIE', 'wordpresspass_'. COOKIEHASH);
define('COOKIE_DOMAIN', false);
wp_setcookie($user_username, $login_password, false, $blogurl, $blogurl, $remember);
// End WordPress Cookie Handling
Here’s the code for logging out:
// Begin WordPress Cookie Handling
require_once("blog/wp-includes/pluggable-functions.php");
$blogurl = "http://www.fantasyblitz.com/blog";
$cookiehash = md5($blogurl);
define('COOKIEHASH', $cookiehash);
define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH);
define('PASS_COOKIE', 'wordpresspass_'. COOKIEHASH);
define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', $blogurl . '/' ) );
define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', $blogurl . '/' ) );
define('COOKIE_DOMAIN', false);
wp_clearcookie();
// End WordPress Cookie Handling
Bah, this isn’t working for me… any ideas?
I’m trying to integrate the login in phpizabi and wordpress.