Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.