PHP - CURL - redirecting to main domain after login, which I don't want

Discussion in 'PHP' started by ahdsan, Sep 2, 2013.

  1. #1
    I am using curl to logging in to a aspx file. I have managed to login but after login, it goes to the main site.
    for example,

    $url="https://www.test.com"
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
    curl_setopt($ch, CURLOPT_REFERER, $url1);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_STDERR, $f);
    curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    $ret = curl_exec($ch); // Get result after login page.
    curl_close($ch);

    after this it redirects to the main site, while I need to stay on localhost and get another page. if I give Followlocation=1 it goes to the main site and if I give Followlocation=0 it says 'Object Moved here"

    I want the output stored in a variable after login.
     
    ahdsan, Sep 2, 2013 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    try to comment this line curl_setopt($ch, CURLOPT_REFERER, $url1);
     
    bartolay13, Sep 4, 2013 IP