I am using the WordPress API to get the user login. My code:
<?php
define('WP_USE_THEMES', false);
require('wp-blog-header.php');
$creds = array();
$creds['user_login'] = 'user';
$creds['user_password'] = 'password';
$creds['remember'] = true;
$user = wp_signon( $creds, false);
if ( is_wp_error($user) )
echo $user->get_error_message();
$cookie = wp_set_auth_cookie($user->ID); ?>
these codes are working on my main domain www.mydomain
but i installed wordpress on blog.mydomain
I think there is a cookie problem. I tested the codes above on subdomain and i got user logged in.
So how can i solve the problem?
P.s : there isnt problem with including "wp-blog-header.php"
I am using the WordPress API to get the user login. My code:
<?php
define('WP_USE_THEMES', false);
require('wp-blog-header.php');
$creds = array();
$creds['user_login'] = 'user';
$creds['user_password'] = 'password';
$creds['remember'] = true;
$user = wp_signon( $creds, false);
if ( is_wp_error($user) )
echo $user->get_error_message();
$cookie = wp_set_auth_cookie($user->ID); ?>
these codes are working on my main domain www.mydomain
but i installed wordpress on blog.mydomain
I think there is a cookie problem. I tested the codes above on subdomain and i got user logged in.
So how can i solve the problem?
P.s : there isnt problem with including "wp-blog-header.php"
I solved the problem. Here's the solution.
Add this line to your wp-config.php :
define('COOKIE_DOMAIN', '.yourdomain');
save the file and upload. That's all.