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

The Archive Base Latest Questions

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

I have a (.NET) application that calls a PHP app, residing on a different

  • 0

I have a (.NET) application that calls a PHP app, residing on a different subdomain, via AJAX.
To break down the problem, I wrote a simple test script:

<?php
setcookie('test', '1234', time()+60*60*24*30, '/', '.mydomain.com'); 
header('Access-Control-Allow-Origin: *');
echo 'Cookies: '; print_r($_COOKIE); 
?>

If called by direct request, the script behaves as expected – spits out an array with all the .mydomain.com cookies and sets the ‘test’ cookie.

Let’s assume that I’m calling app2.mydomain.com/cookieTest.php from app1.mydomain.com/page1.aspx.

app1 is running on an IIS server, app2 on a Nginx (Linux) server.

So, on app1.mydomain.com/page1.aspx I run this JS:

$.ajax({
    'url' : 'https://app2.mydomain.com/cookieTest.php', 
    'success': function(r){
        $('#container').html(r); 
    }
});

The script returns an empty array for $_COOKIE and attempts to set a cookie but it fails.
The response header looks like this:

Request Headers
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Host:app2.mydomain.com
Origin:https://app1.mydomain.com
Referer:https://app1.mydomain.com/page1.aspx
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1

Response Headers
Access-Control-Allow-Origin:*
Connection:keep-alive
Content-Type:text/html
Date:Fri, 21 Sep 2012 20:54:12 GMT
Server:nginx
Set-Cookie:test=1234; expires=Sun, 21-Oct-2012 20:54:12 GMT; path=/; domain=.mydomain.com
Transfer-Encoding:chunked

(note the set-cookie, which the browser ignores)

What can be going wrong here?

  • 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-12T15:18:59+00:00Added an answer on June 12, 2026 at 3:18 pm

    After some more research ( http://www.bradchen.com/node/28 and https://developer.mozilla.org/en-US/docs/HTTP_access_control ) I realized that this is not achievable directly, but there are workarounds for both ways (getting and setting).

    It’s actually pretty easy: you can get the PHP app to read cookie values by passing a session ID or whatever else is in the cookies that we want to pass, and setting new cookies by parsing PHP’s headers_list() and creating a JS that lets the browser set those cookies.

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

Sidebar

Related Questions

I have an asp.net MVC3 application that makes Ajax calls to the server on
I have an ASP.NET application that calls other web services through SSL (outside the
I have a .NET application that uses some API calls, for example GetPrivateProfileString .
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is
Here's the core problem: I have a .NET application that is using COM interop
I have a Php application running on my Server A that consumes a .NET
I have an ASP.NET web application that calls a .NET DLL, that in turn
I have an ASP.Net application that calls an Amazon Web Service to start a
I have an Asp.Net application that calls some WCF service using a proxy generated
I have an ASP.NET web application that calls a web service on a remote

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.