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

  • Home
  • SEARCH
  • 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 8597549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:56:18+00:00 2026-06-12T00:56:18+00:00

UPDATED SCRIPT I am trying to login to a web page and save the

  • 0

UPDATED SCRIPT

I am trying to login to a web page and save the session in a text file.

The login was success and redirect me to the members page or other page if i need.

but now i need download a file with curl, and the server says Fatal error: Out of memory

  ini_set("memory_limit","2048M");    //Limite 2GB
  set_time_limit(0);                  //Tiempo de transferencia ilimitada

  //Definimos las variables de la pagina
  $username    = ""; 
  $password    = "";
  $loginUrl    = 'http://login.mysite.com/login.php';
  $loginFields = array('username' => $username, 'password' => $password);

  //Ahora se ha iniciado la sesion y la sesion de la cookie ha sido generada
  getUrl($loginUrl, 'post', $loginFields); 

  //Cargamos la pagina que queremos ver
  $remote_page_content = getUrl('http://miembros.mysite.com/3098');
  echo $remote_page_content;

  //Simple funcion para acceder
  function getUrl($url, $method='', $vars='') 
  {
        $ch = curl_init();
        if ($method == 'post') 
        {
        curl_setopt ($ch, CURLOPT_POST, 1);
        curl_setopt ($ch, CURLOPT_POSTFIELDS, $vars);
        }

        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
        curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
        curl_setopt ($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
        curl_setopt ($ch, CURLOPT_MAXREDIRS, 10);
        curl_setopt ($ch, CURLOPT_TIMEOUT, 0);
        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);
        curl_setopt ($ch, CURLOPT_FAILONERROR, true);
        curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
        $buffer = curl_exec($ch);
        curl_close ($ch);

        return $buffer;
  }

so i call download file with this:

  //Cargamos la pagina que queremos ver
  $remote_page_content = getUrl('http://content.mysite.com/PSP.mp4/');
  file_put_contents('/downloads/video.mp4',file_get_contents($remote_page_content));

any idea?

thanks

  • 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-06-12T00:56:19+00:00Added an answer on June 12, 2026 at 12:56 am

    Try replacing your following lines:

    curl_setopt ($ch, CURLOPT_COOKIEJAR,  $cookies);
    curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookies);
    

    for this one:

    curl_setopt ($ch, CURLOPT_COOKIEJAR,  $cookie);
    curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie);
    

    as it seems you made a typo in the variable, you want the filename($cookie) not the already closed descriptor ($cookies). This is inside your login() function.

    UPDATE:
    If you are working with multiple pages during ONE session, try adding this:

    curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE); 
    curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id()); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have updated my jSon object using the code <script type=text/javascript > jQuery(document).ready(function($){ var
My goal is to update the web page with some file. When I edit
I am trying to use an automated script, which would login to SVN, update
I'm trying to write a DML script that updates a column but I wanted
I have a script that waits until some row in a db is updated:
I'm new to js/jQuery. Forgive this horrible script. I'm lost. *(Updated with global variable
The following script will update the database, but it won't display the correct page
I'm trying to create an FTP script that will copy a local folder structure
i am new to php, i am trying to upload a file to a
I'm trying to make an experimental web application which minimises redundant data. I have

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.