Hello, Here is my code to login $tmp_fname = tempnam("/tmp", "COOKIE"); $post = array( 'username=user', 'password=xxxx', ); $post = implode('&', $post); $curl_handle = curl_init ("http://example.com/login.php"); curl_setopt ($curl_handle, CURLOPT_COOKIEJAR, $tmp_fname); curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $post); $output = curl_exec ($curl_handle); $curl_handle = curl_init ("http://example.com/ads.php"); curl_setopt ($curl_handle, CURLOPT_COOKIEFILE, $tmp_fname); curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, true); $output = curl_exec ($curl_handle); echo $output PHP: This code works. The problem is that I want to redirect to the remote site. But not saved session .. or do not know how to use cookies. Can anyone tell how after I made a successful remote authorization, I can navigate through the remote site. Lost session mybe.. Thanks.
What have you tried to use to navigate the site? The second part of the code above should work for multiple URLs unless the website checks for valid user agents.
Well I think it is easy to redirect page after authentication. Simply the with you $output variable. <?php $tmp_fname = tempnam("/tmp", "COOKIE"); $post = array( 'username=user', 'password=xxxx', ); $post = implode('&', $post); $curl_handle = curl_init ("http://example.com/login.php"); curl_setopt ($curl_handle, CURLOPT_COOKIEJAR, $tmp_fname); curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $post); $output = curl_exec ($curl_handle); $curl_handle = curl_init ("http://example.com/ads.php"); curl_setopt ($curl_handle, CURLOPT_COOKIEFILE, $tmp_fname); curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, true); $output = curl_exec ($curl_handle); echo $output //redirection if($output == "authorized"){ header("location:desired.url"); //redirection end } ?> PHP: