Re: CURL ignores $_SESSION???



On Sun, 18 Feb 2007 17:02:36 +0100, turnitup <same@same> wrote:

turnitup wrote:
I have a security mechanism that checks that session variables are set, and if not, redirects. It seems, however, that CURL just ignores this statement and completely breaches my security.
Does anyone have any ideas how to avoid this?


It seems that CURL ignores the redirect header. I had to put an exit after that statement. Sorted now. CAVEAT REDIRECTOR!!!

Which is why redirecting should actually be done like this:

<?php
$target = 'http://example.com';
header("Location: $target");
print("You are being redirected to $target, click <a href=\"$target\">here</a> if you don't get redirected.");
exit;
?>

NOt only cURL, but all kinds of applications & browsers can choose not to directly follow your location headers. If you open pages with cURL, and you want to obey redirects from the header, use:
curl_setopt($curl,CURLOPT_FOLLOWLOCATION, true);
--
Rik Wasmus
.



Relevant Pages

  • Re: CURL redirect not working even with CURLOPT_FOLLOWLOCATION set to true
    ... settings as I used to be able to get CURL to follow redirects by ... away, but I still can't seem to follow redirects, but I don't receive ... but it would be a lot easier if the CURL ... // close CURL resource, ...
    (comp.lang.php)
  • Re: CURL redirect not working even with CURLOPT_FOLLOWLOCATION set to true
    ... settings as I used to be able to get CURL to follow redirects by ... away, but I still can't seem to follow redirects, but I don't receive ... but it would be a lot easier if the CURL ... // close CURL resource, ...
    (comp.lang.php)
  • Header Redirect Takes Forever!
    ... redirects the user to another page using the ... a lot of these scripts slowed to ... "exit;" right after the headerline. ... right after a header() now required in PHP? ...
    (php.general)
  • Re: CURL redirect not working even with CURLOPT_FOLLOWLOCATION set to true
    ... I have a feeling this has something to do with my host's server ... settings as I used to be able to get CURL to follow redirects by ... away, but I still can't seem to follow redirects, but I don't receive ... but it would be a lot easier if the CURL ...
    (comp.lang.php)
  • Re: CURL ignores $_SESSION???
    ... set, and if not, redirects. ... It seems, however, that CURL just ignores this statement and completely breaches my security. ... It seems that CURL ignores the redirect header. ... You always have to put exit after redirection. ...
    (comp.lang.php)