Cakephp wordpress auto login
-
Hi All,
When users register on my main site, it uses the WordPress database. The accounts share the same username and password.
Now when users login to my main site, I want the user to login into WordPress automatically. How can I do this?
To achieve this I set a cookie to match that of wordpress cookie(In case we use wordpress login form to login) in the following manner. I call this script after logging into main site.
$cookiehash = md5($blog_directory_web_path);
$siteCookiePath = ‘/blog/forum/’;// WordPress is working with bbpress
define(‘COOKIE_DOMAIN’, false);
$expiration = 0;
if($remember){$expiration = $expire = time() + 1209600;
}else{
$expiration = time() + 172800;
$expire = 0;
}$data = $username . ‘|’ . $expiration;
$key = hash_hmac(‘md5’, $data, ‘phrase 1’);
$hash = hash_hmac(‘md5’, $data, $key);
$cookie = $username . ‘|’ . $expiration . ‘|’ . $hash;setcookie(‘wordpress_’.$cookiehash, $cookie, $expire, $siteCookiePath, COOKIE_DOMAIN);
setcookie(‘wordpress_’.$cookiehash, $cookie, $expire, ‘/’, COOKIE_DOMAIN);
How can I set wordpress Cookie from Outside WordPress2.6.1.
Following links are useless.
http://wordpress.org/support/topic/81942
http://mu.wordpress.org/forums/topic.php?id=4056
http://codex.wordpress.org/WordPress_CookiesI am using 2.6.1.
Please help.
Regards,
Ranjan -
- The topic ‘Cakephp wordpress auto login’ is closed to new replies.