'Is there a way to access WordPress logged user from another asp.net site?

I have 2 totally separate sites, first is WordPress, and second is asp.net. I need when a user open asp.net website, check if he didn't logged in WordPress site, redirect to login form of WordPress.



Solution 1:[1]

You Can Call Api To Asp.net After User Logged Action And Loggout Acction With The Below Code you can use this code in your functions.php At Your Active Theme

<?php
function your_function( $user_login, $user ) {
    // your code
    // Clall APi To Asp.net -> User Logged IN  
}
add_action('wp_login', 'your_function', 10, 2);
?>

For Logout, You Can Call Another API

function wpdocs_redirect_after_logout() {
 
     $current_user   = wp_get_current_user();
  // Your Api Code Here 
 
 }
 add_action( 'wp_logout', 'wpdocs_redirect_after_logout' );

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pro4soft