Im trying to setup a wordpress 1 click login to our companies wordpress sites, we have many. Ive been asked to create one and not use a third party.
Ive managed to use PHP cURL to send a login request and successfully redirect to wordpress after the request, everything works except for when i redirect wordpress throws the error
ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.
My guess is because no method is setting an authentication cookie or something along those lines, It would be great to get this working.
My Current Code
$username = "admin"; $password = "password"; $url = "http://www.example.com/"; $postdata = "log=" . $username . "&pwd=" . $password . "&wp-submit=Log%20In&redirect_to=" . $url . "wp-admin/&testcookie=1"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url . "wp-login.php"); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 0); curl_setopt ($ch, CURLOPT_REFERER, $url . "wp-login.php"); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); curl_close($ch); echo $result; exit;
As mention this code works as in it gets me to the login page but i get that error i mentioned above.
Does anyone know how to either set this cookie myself or get rid of the error to enable successful wordpress logins?