php - How to keep login when curl and go to any page of that website -
function loginpage($loginurl, $loginset, $agent, $cookie){ $options = array( curlopt_ssl_verifypeer => true, curlopt_ssl_verifyhost => 0, curlopt_ssl_verifypeer => 0, curlopt_cookiesession => true, curlopt_connecttimeout => 120, curlopt_useragent => $agent, curlopt_timeout => 120, curlopt_followlocation => true, curlopt_returntransfer => true, //curlopt_referer => 1, curlopt_post => 1, curlopt_header => 0, curlopt_postfields => $loginset, curlopt_post => 1, curlopt_cookiejar => $cookie, //curlopt_cookie => $strcookie, //curlopt_cookiefile => $cookie, ); $ch = curl_init( $loginurl ); curl_setopt_array( $ch, $options ); $result = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); return $result; } $username = "myusername..."; $password = "mypassword..."; $loginurl = "http://up.4share.vn/?control=login"; $loginset = "inputusername=$username&inputpassword=$password"; $cookie = "/uploads/4sharevn_cookie.txt" ; $agent = "mozilla/5.0 (windows nt 6.2; wow64) applewebkit/537.36 (khtml, gecko) chrome/27.0.1453.116 safari/537.36"; $loginpage = loginpage($loginurl, $loginset, $agent, $cookie); echo $loginpage;
with code can curl , login account to: http://up.4share.vn/?control=login
my question how can keep login , go page of website
ex: http://up.4share.vn/?control=account_info
and show in php, please.
you can enable automatic cookie management handling sessions in curl via cookie jar :
curl_setopt($ch, curlopt_cookiejar, '/where/you/want/to/store/cookie.txt');
make sure directory writable
Comments
Post a Comment