Cookie problem

Status
Not open for further replies.

laplagam

Beta member
Messages
5
Hi,

I'm having a cookie issue when using cross domain systems and I'm trying to make a check whether or not the cookie gets blocked.

How it is set up:

domain1: checkcookies.php -> Sends httprequest to the 2 files below from domain2.

domain2: createcookie.php -> creates a cookie
domain2: cookieexist.php -> checks if the created cookie exist. If it exists it prints "1" to the screen. If it doesn't it prints "0"

The weird thing is that even though the cookie exist, the domain1 check prints "0" even though the check is done in domain2, and domain 2 prints the result.

Anyone know what the problem might be? Or possibly other ways of doing this?
 
I'll add some code so you can see what im trying to do. Checkcookies is currently an ASP file.
------------------
Checkcookies.asp(domain1):

dim xmlHTTP, xmlParams, xmlURL

createCookie()
checkIfCookieExists()

Sub createCookie()
set xmlHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")

xmlURL = "http://www.domain2.com/cookie/createcookie.php"
xmlHTTP.open "GET", xmlURL, false
xmlHTTP.setRequestHeader "Content-Type", "text/xml"
xmlHTTP.send
set xmlHTTP = Nothing

End Sub

Sub checkIfCookieExists()
set xmlHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")

xmlURL = "http://www.domain2.com/cookie/cookieexist.php"
xmlHTTP.open "GET", xmlURL, false
xmlHTTP.setRequestHeader "Content-Type", "text/xml"
xmlHTTP.send
response.write xmlHTTP.responseText
set xmlHTTP = Nothing
End Sub

response.end

------------------------

createcookie.php (create cookie, domain2)

<?php

setcookie("testcookie", "some stuff", time()+3600);

?>

-------------------------

cookieexist.php (checkcookie, domain2)

if(isset($_COOKIE['testcookie']))
{
echo "1";
}
else
{
echo "0";
}

-----------------------------
 
Status
Not open for further replies.
Back
Top Bottom