Php simulated login, jump to page problems

Source: Internet
Author: User
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.