• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cookies by cfm may retrieved by php

New Here ,
Nov 24, 2010 Nov 24, 2010

Copy link to clipboard

Copied

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);
?>

Views

4.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 24, 2010 Nov 24, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 25, 2010 Nov 25, 2010

Copy link to clipboard

Copied

what about iframe(of php page) inside cfm, is it correct?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 25, 2010 Nov 25, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 25, 2010 Nov 25, 2010

Copy link to clipboard

Copied

I tried on a live server but php always give NULL as country in

database table country field, the default...can actually run two server side code scripts using iframe in the same page?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 25, 2010 Nov 25, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 26, 2010 Nov 26, 2010

Copy link to clipboard

Copied

<?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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 28, 2010 Nov 28, 2010

Copy link to clipboard

Copied

Owainnorth wrote:

Don't see why not, cookies are based on a domain, not a technology.

Cookies may in fact depend on the technology. For example, I don't expect PHP to be able to make anything of Coldfusion's CFID and CFToken cookies.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 28, 2010 Nov 28, 2010

Copy link to clipboard

Copied

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

http://www.figleaf.com/

http://training.figleaf.com/

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:

http://forums.adobe.com/thread/607238

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 28, 2010 Nov 28, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 03, 2010 Dec 03, 2010

Copy link to clipboard

Copied

cfml cookie set as
<cfcookie name="countNumVisitor" value="#countNumVisitor#" expires="never" >

firefox shows correct value for cookie but php do es not print it....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2010 Dec 04, 2010

Copy link to clipboard

Copied

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

http://www.figleaf.com/

http://training.figleaf.com/

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:

http://forums.adobe.com/thread/607238

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 05, 2010 Dec 05, 2010

Copy link to clipboard

Copied

As you see url in iframe is relative, so same host [shared hosting environment]...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 05, 2010 Dec 05, 2010

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 05, 2010 Dec 05, 2010

Copy link to clipboard

Copied

<cfcookie domain="mydomain.co.uk"

required in this case the domain attribute?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 05, 2010 Dec 05, 2010

Copy link to clipboard

Copied

I'm not sure, why don't you try it and see?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 05, 2010 Dec 05, 2010

Copy link to clipboard

Copied

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

http://www.figleaf.com/

http://training.figleaf.com/

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:

http://forums.adobe.com/thread/607238

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 05, 2010 Dec 05, 2010

Copy link to clipboard

Copied

on different hosts within the same domain

what you mean? the two files are in the same folder the root folder...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 06, 2010 Dec 06, 2010

Copy link to clipboard

Copied

<cfcookie domain="mydomain.co.uk" name="testvar" value="Yee-hah!" />

what to do in cfml so cookie valid in all url, all folders and all subfolders? 

this is valid:  domain="mydomain.co.uk/folder/"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 06, 2010 Dec 06, 2010

Copy link to clipboard

Copied

If you just use this:

<cfcookie name="foo" value="bar">

the cookie will be available for every page on that host.

If you use a DOMAIN attribute, the cookie will be available for every page within that domain.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Read this before you post:

http://forums.adobe.com/thread/607238

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 06, 2010 Dec 06, 2010

Copy link to clipboard

Copied

I used

<cfcookie domain="mydomain.co.uk/folder/" name="testvar" value="Yee-hah!" expiries="never" />

but still can NOT get cookie from file.php(iframe in cfml page, same cfml page, set the cookie), can you send a simple working snipet cfml/php using iframe that works?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 06, 2010 Dec 06, 2010

Copy link to clipboard

Copied

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

http://www.figleaf.com/

http://training.figleaf.com/

Read this before you post:

http://forums.adobe.com/thread/607238

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 07, 2010 Dec 07, 2010

Copy link to clipboard

Copied

> can you send a simple working snipet cfml/php using iframe that works?

What's wrong with the completely working example I've already posted up for you?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 07, 2010 Dec 07, 2010

Copy link to clipboard

Copied

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;


?>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 07, 2010 Dec 07, 2010

Copy link to clipboard

Copied

In your PHP doc, change:

  echo($_COOKIE['countNumVisitor']);

To:

  echo($_COOKIE['COUNTNUMVISITOR']);

Dunno about yours, but mine seems to insist on an upper case cookie name.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation