Remote login using curl (4 posts)

  1. spathon
    Posted 5 years ago #

    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

  2. mrlb
    Posted 5 years ago #

    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.

  3. spathon
    Posted 5 years ago #

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

  4. mrlb
    Posted 5 years ago #

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


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

    var dataString = log=username&pwd=password&wp-submit=Log+In&testcookie=1;
    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.

Topic Closed

This topic has been closed to new replies.

About this Topic