dbo Posted September 22, 2008 Share Posted September 22, 2008 I'm trying to automate some login capability to an online service (webmail). I'm successfully posting the values to the page, but receiving a response that cookies are not enabled. Here's the code: $url = "https://mail.mydomain.com/"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . "cookie.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . "cookie.txt"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "loginOp=login&username=user&password=pass&remember=0&client=preferred"); $result = curl_exec($ch); curl_close($ch); echo $result; In the current directory I don't see any cookies which leads me to believe that the cookies are truly not being created. cURL isn't generating any error messages... is there some other way I'm not aware of for capturing errors? Other potentially useful information. I'm running the above code on localhost (not the same server as the webmail resource). Though I don't think this matters because when I created a generic HTML form I could in fact login from localhost. Link to comment https://forums.phpfreaks.com/topic/125330-curl-and-cookies/ Share on other sites More sharing options...
dbo Posted September 22, 2008 Author Share Posted September 22, 2008 *bump* Has anyone ever tried bypassing login forms which require cookies to be enabled? Link to comment https://forums.phpfreaks.com/topic/125330-curl-and-cookies/#findComment-648070 Share on other sites More sharing options...
dbo Posted September 23, 2008 Author Share Posted September 23, 2008 One more time... any ideas? Link to comment https://forums.phpfreaks.com/topic/125330-curl-and-cookies/#findComment-648592 Share on other sites More sharing options...
JonnoTheDev Posted September 23, 2008 Share Posted September 23, 2008 Try ammending the cookie path to your server tmp directory. Had no problems setting cookies with curl using this: $cookiePath = "/tmp/cookies.txt"; curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiePath); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiePath); Link to comment https://forums.phpfreaks.com/topic/125330-curl-and-cookies/#findComment-648623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.