Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7164623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:06:19+00:00 2026-05-28T14:06:19+00:00

My cURL script does not work anymore (so keep in mind it DID work

  • 0

My cURL script does not work anymore (so keep in mind it DID work before) on my localhost (so it DOES work on my external host, hence: it might be the server settings):

This script worked fine before on my localhost (it still does on my host). Nothing changed.

  • Maybe the fact that I’ve ran this script over 3000 times on my localhost is useful to know.
  • I’m running on windows 7, using WampServer to setup a host.
  • I might have changed a setting, which effects the writing of cookies. But which one?

REAL PROBLEM: cURL does not set a cookie! What apache modules should be ON for writing cookies (in a .txt file)? I’m running wampserver.

Please note I’m already using:

    curl_setopt($curlTable, CURLOPT_COOKIEJAR, 'cookie.txt');
    curl_setopt($curlTable, CURLOPT_COOKIEFILE, 'cookie.txt');

And that php.ini is:

extension=php_curl.dll is uncommented
  • Side question: Does curl_close unset the cookie? And if the cookiejar option is not set?
  • Main question: Why doens’t curl write a cookie like it should do (and does on my external host, NOT on my LOCALHOST.

Other information:

phpinfo()

curl
cURL support        enabled
cURL Information    7.21.7
Age                 3
Features
AsynchDNS           Yes
Debug               No
GSS-Negotiate       Yes
IDN                 No
IPv6                Yes
Largefile           Yes
NTLM                Yes
SPNEGO              No
SSL                 Yes
SSPI                Yes
krb4                No
libz                Yes
CharConv            No
Protocols           dict, file, ftp, ftps, gopher, 
                    http, https, imap, imaps, ldap, pop3,
                    pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
Host                i386-pc-win32
SSL Version         OpenSSL/0.9.8r
ZLib Version        1.2.5
libSSH Version      libssh2/1.2.7 

Currently using:

preg_match('/name="csrf" value="(.*?)"/', $getTokenCurlData, $token);

$postFields = array(
    'user'     => $userNum,
    'paswoord' => $userPass,
    'login'    => 'loginform',
    'csrf'     => $token[1]);

// 'user='.$userNum.'&paswoord='.$userPass.'&login=loginform&csrf='.$token[1]

$postData = http_build_query($postFields);

    $curlTable = curl_init();
    curl_setopt($curlTable, CURLOPT_URL, 'link');
    curl_setopt($curlTable, CURLOPT_COOKIEJAR, 'cookie.txt');
    curl_setopt($curlTable, CURLOPT_COOKIEFILE, 'cookie.txt');
    curl_setopt($curlTable, CURLOPT_ENCODING, 'gzip');
    curl_setopt($curlTable, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($curlTable, CURLOPT_POST, true);
    $tableData = curl_exec($curlTable);
    if (!$tableData) echo 'post problem?'.$tableData;
    if ($tableData == false)
{
    echo 'Curl error: ' . curl_error($curlTable);
}

    curl_close($curlTable);
// Here I further process my data.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:06:20+00:00Added an answer on May 28, 2026 at 2:06 pm

    Probably you was banned at the login process. This will give you more info about the problem:

    // change 
    // if (!$siteSource) echo 'Help!';
    // to
    if ($siteSource === false)
    {
        echo 'Curl error: ' . curl_error($curl);
    }
    

    EDIT: some other opt that you can try (SSL related solved my problems more that one time):

    curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)');
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_VERBOSE, 1);
    
    // following is very important
    // TRUE to follow any "Location: " header that the server sends
    // as part of the HTTP header (note this is recursive, PHP will follow
    // as many "Location: " headers that it is sent, unless CURLOPT_MAXREDIRS is set).
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    

    EDIT 2: Following opt will give you the headers returned (use only to debug). Besides be sure about the cookie.txt is being used properly (locatable and writable).

    curl_setopt($curl, CURLOPT_HEADER, true);
    

    That’s all I can contribute by my side. Now lo lunch!


    EDIT 3: Cookie related stuff:

    $cookie_file = PATH_TO_YOUR_COOKIE_FILE . '/cookie.txt';
    
    if (! file_exists($cookie_file) || ! is_writable($cookie_file))
    {
        echo 'Cookie file missing or not writable.';
        exit;
    }
    
    // you already added the following, I put it again just to remark their utility
    curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file);
    curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file);
    

    EDIT 4: Always check this at the beginning:

    if ( ! extension_loaded('curl'))
    {
        echo "You need to load/activate the curl extension.";
    }
    

    If you receive this error, activate curl in php.ini uncommenting/removing the front ;

    windows:
    ;extension=php_curl.dll // or curl.dll
    linux:
    ;extension=php_curl.so // or curl.so
    

    and restart the web server. If you do not found this line then you need install curl:

    // ubuntu
    sudo apt-get install php5-curl
    
    // centos
    sudo yum install php5-curl
    

    For windows or your wampserver it must be easy too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to install python below way. But this did not work. This take
Ok for some reason my script does not return any data from a JSON
This works: curl --url http://someurl.tld --form apikey=39485730 This does not: curl --url http://someurl.tld --form
I'm trying to use cURL in a script and get it to not show
i wanna using curl in php script and run it in command line mode.
I have a PHP script that uses CURL to fetch a remote page and
I'm writing a script to download files from an FTP server using cURL +
Okay, so I am basically making a script to pass post data using cURL.
I have installed WAMP and running PHP scripts on localhost. I have enabled cURL.
does curl function need any special option to post multipart/form-data ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.