php - Check if a user is logged into my WordPress site which is on a different server

admin2025-01-07  3

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.

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.

Share Improve this question edited Aug 28, 2017 at 12:41 user3438958 asked Aug 28, 2017 at 11:26 user3438958user3438958 4391 gold badge7 silver badges16 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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

Check wordpress_logged_in_[hash] from your remote server

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736257678a456.html

最新回复(0)