cookies by cfm may retrieved by php? if iframe have or not (other page)?
In a cfm page may insert:
<iframe src="country.php" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" width="0" height="0" style=" border:none"></iframe>
where country.php: // to get ip I used $_COOKIE['countNumVisitor'] set by cfm, get by php, well seems default NULL appear in country always, where error?
<?php
function getIP()
{
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if (isset($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
else $ip = “UNKNOWN”;
return $ip;
}
$ipNEW = getIP();
$IP=$ipNEW;
if ((!empty($IP)) && ($IP != "UNKNOWN")){
$country = file_get_contents('http://api.hostip.info/country.php?ip='.$IP);
} else
$country = 'unknown';
include("pass/passwords.php");
$linkid = mysql_connect($hostname,$username,$password);
@mysql_select_db($database,$linkid) or die( "Unable to select database");
$countNumVisitor=$_COOKIE['countNumVisitor']);
$query15 = "INSERT INTO yyyy SET country='$country' WHERE countNumVisitor = $countNumVisitor"; // refURL
$result15 = @mysql_query($query15,$linkid) or die("Unable to execute query. Please try again later. line 168"); // linkid2
mysql_close($linkid);
?>
Don't see why not, cookies are based on a domain, not a technology.
Try creating a simple cookie using CFCOOKIE then try reading it in with PHP in the way you normally would, I don't see why it wouldn't work. Bear in mind if you're using doing the write and read on the same page that I'm not sure at what point CF would write the cookie, whether it's as the page *begins* to render or finishes rendering.
Therefore the cookie may not be immediately apparent, but should be easy enough to test.
The contents of an iframe are a separate request to the request for the "main" window. Frames and that sort of thing are a browser conceit: neither the web server nor CF have any idea how the requests will be handled on the browser, they just see two requests. Both of which are handled like any other requests would be. They have no relation to one another.
Why don't you just TRY IT and see if it works? It'll only take 5min to knock together a test...
--
Adam
Like I said: as far as the servers are concerned (web server, CF & PHP servers), they are not "the same page". Servers don't think in "pages" they think in "requests". When a browser requests a web page which in turn has an iframe in it, that's two separate requests: one for the main page, one for the iframe. They only look like "the same page" because that's how the browser chooses to render them. On the server end of things they are two distinct & unrelated requests.
You might need to look at casing issues in regards to the cookie key names. CF always capitalises them, I think, whereas PHP is case-sensitive.
You should probably use an HTTP sniffer to watch what cookie data is being moved too/from the browser/servers for each request. That will probably shed some light on the scene...
--
Adam
<?php
function getIP()
{
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if (isset($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
else $ip = "UNKNOWN";
return $ip;
}
$ipNEW = getIP();
$IP=$ipNEW;
if ((!empty($IP)) && ($IP != "UNKNOWN")){
$country = file_get_contents('http://api.hostip.info/country.php?ip='.$IP);
} else
$country = 'unknown';
include("admin/yyyyy.php");
$linkid = mysql_connect($hostname,$username,$password);
@mysql_select_db($database,$linkid) or die( "Unable to select database");
$countNumVisitor=$_COOKIE['countNumVisitor']);
$query15 = "INSERT INTO yyyy SET country='$country' WHERE countNumVisitor = $countNumVisitor";
$result15 = @mysql_query($query15,$linkid) or die("Unable to execute query. Please try again later");
mysql_close($linkid);
echo $countNumVisitor." ".$country; // firefox shows 239 as cookie but printed nothing[even "iii" not printed]... needed get bigger iframe?
<iframe src="country.php" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" width="100" height="14" style=" border:none">iii</iframe>
It may not be able to match the values of CFID and CFTOKEN to meaningful internal values, but it can certainly read the values if both applications are within the same domain scope. In situations like this, it's fairly common to write a "cookie cracker" - a script which can accept tokens like these and return a user identity. So, you could write a CF program to crack these cookies, then invoke that from your PHP program which received the cookies.
Dave Watts, CTO, Fig Leaf Software
Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.
Read this before you post:
Well yes quite, what the man with the signature said. I never said that PHP would be able to understand a CFID, simply that it could read it, which it can. If you want any kind of communication between PHP and CF I'd assumed you'd not be trying to use the built-in methods for authentication.
Are your CF and PHP applications running within the same host? If not, they won't be able to share cookies unless they're within the same domain and you specify a domain-wide cookie using the DOMAIN attribute of CFCOOKIE.
Dave Watts, CTO, Fig Leaf Software
Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.
Read this before you post:
Right, it's as simple as expected. Two pages:
/index.php:
<?php
echo($_COOKIE['TESTVAR']) ;
?>
/index.cfm:
<cfcookie domain="mydomain.co.uk" name="testvar" value="Yee-hah!" />
<iframe src="/test.php">
</iframe>
Result when index.cfm is called? PHP outputs the value of the cookie as expected. Where's the issue? Or have I missed something?
Only if the CF and PHP applications are on different hosts within the same domain. By default, cookies created with CFCOOKIE are host-specific.
Dave Watts, CTO, Fig Leaf Software
Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.
Read this before you post:
That's not valid syntax for the DOMAIN attribute. If you wanted to ensure that cookies would be sent to www.figleaf.com and training.figleaf.com, you'd use this:
<cfcookie domain=".figleaf.com" ...>
As for a CF/PHP example, I can't do that right now, as the computer I'm using doesn't have either installed. But I may have time tonight to do this.
Dave Watts, CTO, Fig Leaf Software
Read this before you post:
I make two simple [cookie] pages cfm and php linked by iframe but does not work?
http://www.polisphotos.com/store/test2cookie.cfm
<cfcookie domain=".polisphotos.com" name="countNumVisitor" value="222888" path="/" expires="never" >
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<iframe src="country2.php" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" width="100" height="20" style=" border:none"></iframe>
</body>
</html>
http://www.polisphotos.com/store/country2.php
<?php
$countNumVisitor=$_COOKIE['countNumVisitor'];
echo $countNumVisitor;
?>
Worked with caps in my sample but in the project with a web service php inside iframe inside this all in cfm page... well php web services[country by ip] are working in this case? $country = file_get_contents('http://api.hostip.info/country.php?ip='.$IP);
North America
Europe, Middle East and Africa
Asia Pacific