Forum Moderators: open

Message Too Old, No Replies

Image Cookie

         

fallenangel1

11:27 pm on Sep 7, 2007 (gmt 0)

10+ Year Member



Hi, recently i was in a blog and they were talking about an "image cookie" which is basically you have an image and when a person visits the page with that particular image, they get cookied with a chosen link.

I'm wondering how this is possible? How can a jpg or an image file be capable of dropping a cookie?

Thanks.

RonPK

11:49 am on Sep 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One way I can think of would involve a script on the server. The script should first set the cookie and then send the image.

In PHP:

setcookie('somename', 'value');
header('Content-type: image/jpeg');
readfile('the_real_image.jpg'); // this will send the image to the browser
exit();

By modifying server settings you could even call the script

myimage.jpg
and still have the server parse it as a PHP file.