Curl simulated login

Source: Internet
Author: User
Curl simulated login problem This post was last edited by zkg510168343 at 15:29:21 on

$ Url = "http://bbs.lampbrother.net/login.php ";
$ Urls = "http://bbs.lampbrother.net ";
$ Lgt = 0;
$ User = "zkg12345 ";
$ Pass = "123456 ";
$ Question = 0;
$ Hideid = 1;

$ Temp = tempnam ('./tep', 'cookies ');

$ Postdata = "forward = & jumpurl = ". $ urls. "& step = 2 & lgt = ". $ lgt. "& pwuser = ". $ user. "& pwpwd = ". $ pass. "& question = ". $ question. "& answer = & hideid = ". $ hideid. "& cktime = ";
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ postdata );
Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ temp );


$ Data = curl_exec ($ ch );
Curl_close ($ ch );

// Echo $ data; // you can see that the login is successful and the jump is being made.
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, 'http: // bbs.lampbrother.net/index.php ');
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 0 );
Curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ temp );

Curl_exec ($ ch );
Curl_close ($ ch );
?>

After the login is complete, I found that the login was successful when printing, and the page is displayed as a jump, but again requested the home page is still not logged on, other pages are not logged on, what is the problem and how to debug it?

A coo810B. tmp file is generated in the temporary cookie file.
The value is
# Netscape HTTP Cookie File
# Http://curlm.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

.Lampbrother.net TRUE/FALSE 1413961648 4f62d_c_stamp 1382425648
.Lampbrother.net TRUE/FALSE 1350889647 4f62d_lastvisit deleted
.Lampbrother.net TRUE/FALSE 1413961648 4f62d_lastpos other
.Lampbrother.net TRUE/FALSE 1350889647 4f62d_ci deleted
.Lampbrother.net TRUE/FALSE 1413961648 4f62d_ck_info % 2F % 09.lampbrother.net
.Lampbrother.net TRUE/FALSE 1350889647 4f62d_regactivate deleted


Reply to discussion (solution)

Are I dizzy? Let's get a soy sauce. I'll paste it.

Full path!
$ Temp = realpath (tempnam ('./tep', 'cookies '));

Full path!
$ Temp = realpath (tempnam ('./tep', 'cookies '));
The problem has been solved. I 'd like to ask

I just modified $ cookie_file = tempnam ('./temp', 'cooke') here ');
Now, do I have to store the cookie files in the temp folder? I created my own folder. tem won't work.

Forget it, no one else. thank you, xuzuning moderator.

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.