WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the WordPress API to get the user login. My code:

define('WP_USE_THEMES', false);

$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.com but i installed wordpress on blog.mydomain.com

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
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 Nov 20 '12 at 16:31

I solved the problem. Here's the solution.

Add this line to your wp-config.php :

define('COOKIE_DOMAIN', '.yourdomain.com');

save the file and upload. That's all.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.