There are two local Apache files: a. php & amp; B. php. A. The php file first contacts the Host through curl and creates a cookie. Then pass some parameters to B. php, and then B. php will use the cookie created by a. php to contact the Host. How can this problem be achieved? There are two files on the local Apache:
a.php&
b.php.
a.phpFile first
curlContact and create
cookie.
Then pass some parameters
b.php, And then
b.phpUse
a.phpCreated
cookieContact Host.
How can this problem be achieved?
Reply content:
There are two files on the local Apache:a.php&b.php.
a.phpFile firstcurlContact and createcookie.
Then pass some parametersb.php, And thenb.phpUsea.phpCreatedcookieContact Host.
How can this problem be achieved?
Save the cookie. if your native cURL is used, it will be stored as a file.
When you try again, read the saved cookie file.
Let's take a look. It seems that you are tired.
$ Post = '_ EVENTTARGET = & __ EVENTARGUMENT = & __ VIEWSTATE ='; // initialize $ curl = curl_init (' http:///login.aspx '); $ Header = array (); $ header [] = 'host: 113. '; $ header [] = 'connection: keep-alive'; $ header [] = 'cache-Control: max-age = 0'; $ header [] = 'accept: text/html, application/xhtml + xml, application/xml; q = 0.9, image/webp, */*; q = 0.8 '; $ header [] = 'Origin: http://113 . '; $ Header [] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/100 '; $ header [] = 'content-Type: application/x-www-form-urlencoded'; $ header [] = 'referer: http:///login.aspx '; $ Header [] = 'Accept-Encoding: gzip, deflate'; $ header [] = 'Accept-Language: zh-CN, zh; q = 100 '; $ header [] = 'cookie: ASP. NET_SessionId = '. $ cookies; curl_setopt ($ curl, CURLOPT_HTTPHEADER, $ header); // do not output header information curl_setopt ($ curl, CURLOPT_HEADER, 1 ); // save to string instead of output curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1); // post data curl_setopt ($ curl, CURLOPT_POST, 1); // request data curl_setopt ($ curl, CURLOPT_POSTFIELDS, $ post); // whether to capture the redirected page curl_setopt ($ curl, CURLOPT_FOLLOWLOCATION, 1); $ response = curl_exec ($ curl); curl_close ($ curl ); $ rs = strlen ($ response );
Why don't you directly go to require B. php at the end of a. php?