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.