1. Cookie の保存パスを定義します
絶対パスを使用する必要があります
$cookie_jar = dirname(__FILE__)."/pic.cookie";
2. Cookie を取得します
Cookie をファイルに保存します<p>$url = "http://1.2.3.4/";2.$ch = curl_init();</p><p>curl_setopt($ch, CURLOPT_URL, $url);</p><p>curl_setopt($ch, CURLOPT_HEADER, 0);</p><p>curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);</p><p>curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);</p><p>$content = curl_exec($ch);</p><p>curl_close($ch);</p>
<p>$ch = curl_init();</p><p>curl_setopt($ch, CURLOPT_URL, 'http://1.2.3.4/getCheckpic.action?rand=6836.185874812305');</p><p>curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);</p><p>curl_setopt($ch, CURLOPT_HEADER, 0);</p><p>curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);</p><p>$ret = curl_exec($ch);7.curl_close($ch);</p><p>
<p>$post ="name=2&userType=1&passwd=asdf&loginType=1&rand=6836&imageField.x=25&imageField.y=7";</p><p>$ch = curl_init();</p><p>curl_setopt($ch, CURLOPT_URL, "http://1.2.3.4/loginstudent.action");</p><p>curl_setopt($ch, CURLOPT_HEADER, false);</p><p>curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);</p><p>curl_setopt($ch, CURLOPT_POSTFIELDS, $post);</p><p>curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);</p><p>$result=curl_exec($ch);09.curl_close($ch);</p>
<p>$ch = curl_init();</p><p>curl_setopt($ch, CURLOPT_URL, "http://1.2.3.4/accountcardUser.action");</p><p>curl_setopt($ch, CURLOPT_HEADER, false);</p><p>curl_setopt($ch, CURLOPT_HEADER, 0);</p><p>curl_setopt($ch, CURLOPT_RETURNTRANSFER,0); </p><p>curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);</p><p>$html=curl_exec($ch);</p><p>// var_dump($html);</p><p>curl_close($ch);</p>