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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:10:52+00:00 2026-05-12T09:10:52+00:00

All, Sorry – this is probably a very strange question. I’m working on a

  • 0

All,

Sorry – this is probably a very strange question.

I’m working on a Flash RIA. One of the things it does is call an ASP page (that resides on another domain) to retrieve some data.

However, that ASP page requires users to log-in to that site before they’re allowed to call that ASP page.

So, my first attempt at getting this to work in the Flash app was to use loadVars.sendAndLoad() to post the login variables to the login page. This sets the cookies/session variables to establish my “logged-in” status. Then, later, when the Flash app calls the ASP page to request the data it needs, everything works. In other words, the loadVars.sendAndLoad call to the first page logs me in, and that log-in status is maintained (somehow), so that when the Flash app calls the ASP page later, the ASP page believes I’m still logged in.

A fine solution all around, except now the Flash application will be deployed on another domain. In other words, the ASP page (and the login page) are on domainA.com, but the Flash application will be on domainB.com. And Flash apps can’t call URLs on different domains (I know about crossdomain policy files, but for a variety of reasons, that isn’t an option).

So, my next thought was this – set up a PHP page on domainB.com that uses cURL to pass the login variables to the login page. Set up another PHP page on domainB.com that uses cURL to call the ASP page.

Then, I can set my Flash app to call those PHP pages which will act as “proxies”.

However, this doesn’t work. When I call the first PHP page (which passes variables to the login page on domainA.com), I think THAT works. However, if I then call the second PHP page, the ASP page on domainA.com rejects the request, as though I’m not logged in.

In other words, when I run everything out of Flash – it seems like the “logged-in” status is maintained from the first request to subsequent requests. However, when I run everything from the PHP pages, the logged in state isn’t maintained.

The first PHP page seems to log me into the system. But the second PHP page isn’t credited with being logged in.

Any idea how the cookies are handled differently in Flash and PHP that would explain this difference?

I’m happy to provide much more detail, based on any advice or guidance.

Many thanks in advance!

—- EDIT —-

Based on the terrific feedback and suggestions, I’ve gotten this to work. I haven’t had a chance to polish it; it may be that some of the cURL options are unnecessary or redundant. But at least, it works. Here’s the code:

<?php

    $ckfile = tempnam (".", "CURLCOOKIE");

    $url_1 = 'https://somedomain.com/loginService';
    $url_2 = 'https://somedomain.com/getMyData.asp';

    $fields_1 = array(
        'field1'=>"blah",
        'field2'=>"blah",
        'field3'=>"blah",
    );

    $fields_2 = array(
        'fieldX'=>"blah",
        'fieldY'=>"blah",
        'fieldZ'=>"blah",
    );


    $a='';
    $postvars_1 = '';
    foreach($fields_1 as $key=>$value) { 
        $postvars_1.= $a.urlencode($key).'='.urlencode($value); 
        $a='&'; 
    }

    $a='';
    $postvars_2 = '';
    foreach($fields_2 as $key=>$value) { 
        $postvars_2.= $a.urlencode($key).'='.urlencode($value); 
        $a='&'; 
    }

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
    curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);    
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);

    curl_setopt($ch, CURLOPT_URL, $url_1);
    curl_setopt($ch, CURLOPT_POST, count($fields_1));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars_1);
    $result_1 = curl_exec($ch);

    curl_setopt($ch, CURLOPT_URL, $url_2);
    curl_setopt($ch, CURLOPT_POST, count($fields_2));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars_2);
    $result_2 = curl_exec($ch);

    curl_close($ch);

    header("Content-type: text/xml");
    print $result_2;

    unlink($ckfile);

?>

Needless to say, there may be much better ways to accomplish this, or some serious issues with my code. But working is, for now, better than nothing. I’d never have gotten this to work without the help of the community, and the people below. Many, many 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-05-12T09:10:53+00:00Added an answer on May 12, 2026 at 9:10 am

    Can you paste the problem script?

    At first glance i would check that the cookie is being caught and passed onto the second script (caught from curl response and passed into curl for the second request), curl doesn’t automatically handle cookies (i don’t think), you have to play the part of the web browser, saving the response header (containing the cookie).

    I think you script should look like:

    <?php
    
        // first request
    
        $url = 'https://somedomain.com/login/';
    
        $fields = array(
            'field1'=>"aaaaa",
            'field2'=>"bbbbb",
            'field3'=>"ccccc"
        );
    
        $postvars = array();
        foreach($fields as $key=>$value) { 
            $postvars[] = urlencode($key).'='.urlencode($value); 
        }
    
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, count($fields));
        curl_setopt($ch, CURLOPT_POSTFIELDS, implode('&',$postvars));
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
        preg_match('/^Set-Cookie: (.*?);/m', $result, $auth_value);
        curl_close($ch);
    
        // second request
    
        $url = 'https://somedomain.com/getMyData.asp';
        $fields = array(
            'fieldX'=>"xxxx",
            'fieldY'=>"yyyy",
            'fieldZ'=>"zzzz"
        );
    
        $postvars = array();
        foreach($fields as $key=>$value) { 
            $postvars[] = urlencode($key).'='.urlencode($value); 
        }
    
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, count($fields));
        curl_setopt($ch, CURLOPT_POSTFIELDS, implode('&',$postvars));
        curl_setopt($ch, CURLOPT_COOKIE, 'authenticate='.urlencode($auth_value[1]));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
        curl_close($ch);
    
        print $result;
    
    
    ?>
    

    this is presuming that you dont mind the header guff comming back in the first request.

    Good Luck

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

Sidebar

Ask A Question

Stats

  • Questions 277k
  • Answers 277k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The whole class body, i.e. j = i is a… May 13, 2026 at 2:56 pm
  • Editorial Team
    Editorial Team added an answer You probably want Factory Design Pattern. May 13, 2026 at 2:56 pm
  • Editorial Team
    Editorial Team added an answer Here's a Perl oneliner to replace the IPADDR value with… May 13, 2026 at 2:56 pm

Related Questions

All, Sorry in advance - I'm a novice in most of the topics below
All, Sorry - this is probably a very strange question. I'm working on a
First of all I'm sorry for such a question, I look over the internet
First of all, I'm sorry about the feedback-nature of this question. I'm trying to
first of all, sorry if that question is dumb but I´m a total newbie

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.