Php simulated login, jump to the page problem I want to use php simulated login to a website, after login, simulate a search operation (when performing a search operation, it redirects to another page to display the search results ). The problem I encountered now is that I was able to successfully simulate the login, but when simulating the search, the search page will show no login status. How can I solve this problem?
Reply to discussion (solution)
Carry cookie
Php is still a little troublesome. you need to bring the cookie obtained after the first login.
Reference: http://www.php.net/manual/en/function.curl-setopt.php/
The cookie is on, but it still doesn't work.
Nobody knows?
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, 'http: // api.ajaxsns.com/api.php? Key = free & appid = 0 & msg = '. rawurlencode ('who am I ').'? ');
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_COOKIEJAR, "cookie.txt ");
Curl_setopt ($ ch, CURLOPT_COOKIEFILE, "cookie.txt ");
Curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 1 );
$ Htmls = curl_exec ($ ch );
Curl_close ($ ch );
Echo $ htmls;
?>
Check whether the cookie is set. if the interface is correct, it cannot be displayed.
I also want to know this problem. The cookie is just a cookie after login.
When you click different pages on some websites, I use the packet capture software to find that the sessionid value in the cookie is constantly changing. what can I do in this case?