• I’m trying to make link with auto login to a WordPress site on an other domain. I get logged in but don’t leave the current domain and if i go the the wp domain I’m not logged in. And if I use returntransfer I don’t get logged in.
    I have tried some different variants of this code
    Curl login

Viewing 3 replies - 1 through 3 (of 3 total)
  • mrlb

    (@mrlb)

    Mmm I don’t think curl or any other sort of php library will work for remote login. I tried doing a similar thing like you but the problem is wp-login needs to return a cookie to the client requesting machine. In this case since curl is making the reuqest (from the server) the client never gets the cookie and as such when you try visit wp-admin you get directed back to wp-login.

    I was able to do what you are trying to do using jquery and ajax. The down side is that the users browser must support javascript or it must be enabled.

    Thread Starter spathon

    (@spathon)

    Ok thanks. Is the cookies set and working with different domains using ajax?

    mrlb

    (@mrlb)

    Well it should work from any domain as some as you submit the right POST parameters to wp-login.php e.g

    wp-login.php?log=username&pwd=password&wp-submit=Log+In&testcookie=1

    If you use ajax you can submit this POST string e.g

    var dataString = log=username&pwd=password&wp-submit=Log+In&testcookie=1;
    $.ajax({
    type: “POST”,
    url: “/wp-login.php”,
    data: dataString,
    success: function() {
    //jquery example to update the form on success.
    $(‘#login_form’).html(“<div id=’message’></div>”);
    $(‘#message’).html(“<h2>Logged In!</h2>”);
    });
    }
    });
    return false;

    After your Ajax POST query has run, if you’re wordpress login was successful you should have a wordpress authentication cookie on your system which will let you use wp-admin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remote login using curl’ is closed to new replies.