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"
Share Improve this question edited Nov 20, 2012 at 16:31 Chip Bennett 55.1k8 gold badges91 silver badges170 bronze badges asked Nov 20, 2012 at 14:55 MuratMurat 1214 bronze badges 1- Please do not edit titles to indicate solved status. Also, please place solutions as an answer, rather than as an edit to the question. – Chip Bennett Commented Nov 20, 2012 at 16:31
1 Answer
Reset to default 2I 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.