$current_user is empty in WordPress

I’m trying to get the login data from outside of wordpress.

I mean, I have wordpress installed in mysite/wp/ and I’m calling the following functions in mysite/index.php

Read More
include( 'wp/wp-load.php');  
global $current_user;
get_currentuserinfo();
print_r($current_user);

which prints an empty WP_User Object like this:

WP_User Object ( [data] => [ID] => 0 [caps] => Array ( ) [cap_key] => [roles] => Array ( ) [allcaps] => Array ( ) [filter] => ) 

Should I include something else? What am I doing wrong?

Thanks..

Related posts

Leave a Reply

1 comment

  1. I solved my problem, and it could definitely help others too.

    The problem was with my folder structure,
    since it was like

    • mysite.com
    • mysite.com/mypage.php
      • mysite/wordpress/

    the cookies were only valid for wordpress folder, and it’s subdirectories.

    In order to activate the cookies outside wordpress, I installed the root Cookie plugin, and everything works fine now.

    P.S.

    Do NOT change the configuration of root Cookie. Just leave the Domain Name setting as empty.