I am trying to login to my A site from my B site. So I simulate a login form using curl and I expect to redirect to my A site's main member page. But instead my B site url remain on my address bar and my browser shows my Site A login page. I am new to curl. Thank you for reading.
$cc = curl_init($url);
curl_setopt($cc, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($cc, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($cc, CURLOPT_HEADER, true);
curl_setopt($cc, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cc, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($cc, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($cc, CURLOPT_POST, true);
curl_setopt($cc, CURLOPT_POSTFIELDS, $postString);
return curl_exec($cc);
curl_close($cc);
//echo $result;
//exit;
Using curl
your server makes a request to A and receives a response. It has nothing to do with the client.
1) request 2) request (curl)
---> --->
Client (browser) Server B Server A
<--- <---
4) response 3) response
If you want to tell the client something or redirect him, you have to do so in your response to the client. curl
won't do anything like this. For example, use header('Location: http://a.com ')
to redirect the client in step 4.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.