Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

Conversion tag, php loaded on image src, cookies

images php coding issues or problems here.

Moderators: macek, egami, gesf

Conversion tag, php loaded on image src, cookies

Postby kszo » Fri Jun 03, 2011 3:01 am

Hello!

I'm trying to create a conversion tag but got problems with IE, hope you can help me.

I got a web site con domain_A.com where I save some cookies on that server.
Then I give a Conversion tag to domain_B.com to paste it in their website, so I can tell that if it was in domain_A.com and then went to domain_B.com

Here is my code:
domain_A.com/index.php
Code: Select all
<?php
setcookie("flag_id", "0001", time()+60*60*24*365*5);
?>
<html>
<body>
Hello 0001!
</body>
</html>


domain_B.com/index.html
Code: Select all
<html>
<body>
<img src="https://domain_A.com/conversion.php" width="1" height="1" />
</body>
</html>


domain_A.com/conversion.php
Code: Select all
<?php
if(isset($_COOKIE['flag_id'])){
   $current = file_get_contents('data.txt');
   $current .= $_COOKIE['flag_id']."\n";
   file_put_contents('data.txt', $current);
}
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false );
header("Content-type: image/gif");
$width = 1;
$height = 1;
$im = ImageCreateTrueColor($width, $height);
$color = ImageColorAllocate($im, 255, 255, 255);
ImageFillToBorder($im, 0, 0, $color, $color);
ImageGIF($im);
ImageDestroy($im);
?>


This is a sample test code, the real stuff is more complicated.
The big problem is that conversion.php can't read the cookies.
Works when I open conversion.php directly, use same domain, or use Firefox...
What could be missing! :?

Thanks
kszo
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Jun 03, 2011 2:33 am

Re: Conversion tag, php loaded on image src, cookies

Postby gandahar » Thu Jun 09, 2011 5:33 am

what do you want do do exactly ?

i don't understand

but cross domain manipulation is not easy, depending on you server and other stuff

depending on what you want, i think there is better solutions (than cookie) to send data from a server to another..
User avatar
gandahar
New php-forum User
New php-forum User
 
Posts: 112
Joined: Tue Mar 15, 2011 4:05 am

Re: Conversion tag, php loaded on image src, cookies

Postby kszo » Thu Jun 09, 2011 11:41 pm

hi Gandahar,

I solved the problem,
Just needed a P3P

Code: Select all
header('p3p: CP="NOI ADM DEV PSAi COM NAV OUR OTR STP IND DEM"');


Thanks!
kszo
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Jun 03, 2011 2:33 am


Return to PHP coding => Images

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.