If I have a file example.php which loads WordPress and checks if a user is logged in to my WordPress site:

// Load WP
require_once(dirname(__FILE__) . '/wp-load.php' );

// Check if user is logged in and output a test message
if (is_user_logged_in()) {
    echo 'User is logged in';

} else {
    echo 'User is not logged in';

How can I run this file from another website which is on a different server to my WordPress site? As I want to check if the current user viewing website A is logged in to my WordPress website on website B.

It's possible to do it with an ajax request with jsonp, but is there a non JS solution to this?

It won't work with cURL because I don't think it's possible to check if the user is logged in using cURL.

PHP docs states that include() and require() can have external URLs if allow_url_include is set to 1 in php.ini, but I've read there are security concerns to this.

Any help appreciated.

1 Answer 1


I think the best way for you is to share and check wordpress login cookie.

Check wordpress_logged_in_[hash] from your remote server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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