I have created my site in PHP now My Blog site in wordpress so if user logged in PHP site is also logged in Wordpress site it is possible?

  • the answer is "yes" if they are no the same domain and "not easy" otherwise. Jun 29, 2017 at 14:52

1 Answer 1


I found the solution for using below function:

    function auto_login() {
        // make sure user is not logged in and "user" was POST'd
        $username = isset( $_POST['user'] )? $_POST['user'] : false;
        if ( ! is_user_logged_in() && $username ){
            // load the user by username
            $user = get_user_by( 'login', $username ); 
            if ( $user ) {
                // log user in using the $user object properties
                wp_set_current_user( $user->ID, $user->user_login );
                wp_set_auth_cookie( $user->ID );
                do_action( 'wp_login', $user->user_login );

add_action( 'wp_loaded','auto_login' );
  • 1
    hmmm, login without checking the password.... is not a real solution just an accident waiting to happen. it doesn't even answer your own question :( Jul 4, 2017 at 13:58
  • Not login without password, if user logged in PHP site than this function works. Jul 5, 2017 at 6:25
  • you do not check the password anywhere Jul 5, 2017 at 8:27

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.