SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: cURL + https

  1. #1
    SitePoint Addict
    Join Date
    Aug 2005
    Location
    Lithuania, Europe
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cURL + https

    I am having a problem with cURL - I cannot login via https. This is what I have:
    PHP Code:
        $curl = &new cURLManager('https://foobar.com/login.aspx');
        
    $curl->setOption(CURLOPT_HEADERfalse);
        
    $curl->setOption(CURLOPT_POSTtrue);
        
    $curl->setOption(CURLOPT_POSTFIELDS$data_pack); //string of vars (username=foo&password=bar etc)
        
    $curl->setOption(CURLOPT_RETURNTRANSFERtrue);

        
    $curl->setOption(CURLOPT_SSL_VERIFYPEERfalse); //Temporarily used to remove the SSL error
        
    $curl->setOption(CURLOPT_SSL_VERIFYHOSTfalse); //Temporarily used to remove the SSL error

        
    $curl->setOption(CURLOPT_FOLLOWLOCATIONtrue);
        
    $curl->setOption(CURLOPT_REFERER'http://www.foobar2.com');
        
    $curl->setOption(CURLOPT_USERAGENT'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
        
    $data $curl->getOutput(); 
    Upon logging into the site normally via browser, it automatically redirects you to default.aspx page, so it should be the same with cURL. However, with cURL I get the page (actually it's the same login.aspx page) which is displayed if user's session time expires (that is, if logged in user has been inactive for 20 mins or so) or if a restricted page is being accessed without authorization. It doesn't display incorrect username/password message, so it seems the server checks them and accepts them but still doesn't log in properly. If I put incorrect username/password intentionally in $data_pack, I DO get the incorrect username/password message.

    What do you think could be the problem of this login? Maybe I need to set other options in cURL? HTTPS is something I am messing with for the first time, so ANY help/suggestions would be greatly appreciated.

  2. #2
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may need to accept and/or bodge up a cookie for the sessionID

  3. #3
    SitePoint Addict
    Join Date
    Aug 2005
    Location
    Lithuania, Europe
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I need cookies


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •