The server successfully receives login, password and CAPTCHA. How to do this with a cookie?
I do not know what information is needed to help. I will show everything:
Login form:
<div id="loginForm"> <div id="logo"><img src="logo.png" border="0" /></div> <div class="loginBar">Login</div> <form action="index.php" method="post"> <input type="hidden" name="p" value="login" /> <div class="line"> <label>Captcha</label> <img src="captcha/securimage_show.php" border="0" /> </div> <div class="line"> <label> </label> <input type="text" name="captcha" value=""/> </div> <div class="line"> <label> </label> <input type="submit" value="Login" /> </div> </form> <hr/> <a href="index.php?p=register" class="register" title="Click to register">Register</a> </div>
CURL code:
extract($_POST); //set POST variables $proxy = '127.0.0.1:8118'; $url = 'http://example.com/index.php'; $fields_string= 'p=login&user=' . $user . '&pass=' . $passwd . '&captcha=' . $_POST['captcha'] . '&submit=Login'; //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch,CURLOPT_PROXY, $proxy); curl_setopt($ch,CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($ch,CURLOPT_COOKIEFILE, "cookie.txt"); //curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); //execute post $result = curl_exec($ch); print_r(curl_error($ch)); print_r(curl_getinfo($ch)); print_r(curl_errno($ch)); //close connection curl_close($ch);
curl getinfo:
[url] => http:
Real cookie:
Host: example.com Name: PHPSESSID Path: / Content: 7qk7bb17nr030g5j59h2gq3nq6 Content raw: 7qk7bb17nr030g5j59h2gq3nq6 Expires: At end of session Expires raw: 0 Send for: Any type of connection Send for raw: false Created: Fri 25 Nov 2011 10:37:24 PM EET Created raw: 1322253443569272 Last accessed: Sat 26 Nov 2011 11:06:02 AM EET Last accessed raw: 1322298361723991 HTTP only: No HTTP only raw: false This domain only: No This domain only raw: false Policy: no information available Policy raw: 0 Status: no information available Status raw: 0
Gerenated libcurl in cookie.txt:
# Netscape HTTP Cookie File # http:
When I run this code, Account, Passwd and Captcha are successfully accepted by the server, but have a cookie error:
Make sure you enable cookies
I also saw that the true cookie Content Raw is different from the one generated with libcurl.
I also saw that from my form I successfully catch a web server cookie.
PS !! I get a cookie from this link in the login form:
<img src="captcha/securimage_show.php" border="0" />