views:

396

answers:

4

Hi I am trying to find a way to read the cookie that i generated in .net web application to read that on the php page because i want the users to login once but they should be able to view .net and php pages ,until the cookie expires user should not need to login in again , but both .net and php web applications are on different servers , help me with this issue please , thanks

A: 

any cookie given to a browser will be readable by server processing the request --- they're language agnostic.

try $_COOKIE in PHP

A: 

As long as the site is the same (i.e. www.example.com) then cookies are platform agnostic. As Todd Kennedy said try the super global $_COOKIE. If you site is different though you won't be able to read the cookies, they are supposed to be site specific and prevent this type of cross site access.

Rob Booth
A: 

Are the two servers on the machine within the same domain? if so you should set the cookie scope to the domain rather than the FQDN; then both machines will be able to read them;

Response.Cookies["domain"].Domain = "contoso.com";

would allow contoso.com, www.contoso.com, hotnakedhamsters.contoso.com etc to access it.

blowdart
+3  A: 

You mention that :

but both .net and php web applications are on different servers

Are both applications running under the same domain name? (ie: www.mydomain.com) or are they on different domains?

If they're on the same domain, then you can do what you're trying to do in PHP by using the $_COOKIE variable. Just get the cookie's value by

$myCookie = $_COOKIE["cookie_name"];

Then you can do whatever you want with the value of $myCookie.

But if they're on different domains (ie: foo.mydomain.com and bar.mydomain.com), you cannot access the cookie from both sites. The web browser will only send a cookie to pages on the domain that set the cookie. However, if you originally set the cookie with only the top-level domain (mydomain.com), then sub-domains (anything.mydomain.com) should be able to read the cookie.

Mike King
thanks i added the domain (mydomain) and it works