i would like to login a user into my wordpress blog once they have login with my non-wordpress(PHP) website, in order to do this, i have already inserted the user details also in wp-users table with md5 password, and user meta data also,
now how can i do login to the user while login from my website , i have used curl to do this, but it doesn't worked at all , my used code is follow :
$username="admin"; $password="admin"; $url="http://www.yourdomain.com/"; $cookie="cookie.txt"; $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; U; Windows NT 5.1; en-US; rv:220.127.116.11) Gecko/20070725 Firefox/18.104.22.168"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt ($ch, CURLOPT_REFERER, $url . "wp-admin/"); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); curl_close($ch); echo $result; exit;
[Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]
please kindly advise me.