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 7497717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:12:24+00:00 2026-05-29T19:12:24+00:00

Im using MAMP on a Mac running OS X Lion. I need to connect

  • 0

Im using MAMP on a Mac running OS X Lion.

I need to connect to a remote site sending the cookie.
All goes well except for the cookie part.
For the cookie part I’m using this code:

$cookieFile = dirname(__FILE__).'/cookie.txt';
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile); 
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile); 

The CURLOPT_COOKIEJAR part does create a cookie, but on a subsequent request CURLOPT_COOKIEFILE doesn’t add a cookie header. I’ve checked this using HTTPScoop (a Fiddler like tool).

Any idea what might be the problem?

EDIT:
Im connecting to a ASP.Net site. Problem seems to be the im not getting a ASP.NET_SessionId cookie. The cookie i do get has a key without a value, thats probably the reason why it isn’t posted.
Any idea how to force the server to send a session cookie?

  • 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-29T19:12:26+00:00Added an answer on May 29, 2026 at 7:12 pm

    We’d really need to see more code, but here is a sample bit I have which collects a session cookie from an initial request then uses it in a subsequent POST. It uses an anonymous proxy to run a GET request on an arbitrary URL, hopefully it helps you (to be clear though it doesn’t use the COOKIEJAR, but I feel it may still be helpful).

    <?php
    define('TARGET_URL', 'http://moxune.com');
    echo 'Sending initial request' . PHP_EOL;
    $aHeaders = get_headers("http://420proxy.info");
    
    foreach($aHeaders as $sHeader) {
        if(stripos($sHeader, 'set-cookie') !== false) {
            // extract the cookie from the first response
            $aCookie = explode(':', $sHeader);
            $sCookie = trim(array_pop($aCookie));
            $oCookie = http_parse_cookie($sCookie);
    
            echo 'Cookie extracted, trying to POST now' . PHP_EOL;
    
            // OK, now let's try the POST request
            $ch = curl_init('http://420proxy.info/includes/process.php?action=update');
            curl_setopt($ch, CURLOPT_REFERER, '420.proxy.info');
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_COOKIE, $sCookie);
            curl_setopt($ch, CURLOPT_HEADER, true);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    
            curl_setopt($ch, CURLINFO_HEADER_OUT, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect: 100-continue'));
    
            //curl_setopt($ch, CURLOPT_COOKIE, http_build_cookie((array)$oCookie));
            curl_setopt($ch, CURLOPT_POSTFIELDS, array(
                'u' => TARGET_URL,
                'allowCookies' => 'off',
                'encodeURL' => 'off',
                'stripJS' => 'on'
                )   
            );  
    
            $response = curl_exec($ch);
    
            die(var_dump($response));
        }   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am hosting a CodeIgniter site locally using MAMP on my mac. Whenever I
I'm running PHP 5.3.6 with MAMP 2.0.1 on Mac OS X Lion and I'm
I develop using MAMP pro on my Mac. When I start MAMP it prompts
I'm running MAMP 1.7.2 on a Mac and I'd like to install the extension
Hi I am running MAMP on my mac to locally host a website. I
I'm building a site on my home computer using MAMP. The code I'm using
I am using MAMP Pro 1.9.4 on Mac OSX In phpinfo() I see curl
I use MAMP for PHP/MySQL. What do I need for RoR? I am using
I am trying to enable mysqli on Mac OS X. I am using MAMP
I have a simple question. I'm using MAMP for development on my Mac. Once

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.