Setting Cookies

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
lazersam
Forum Contributor
Posts: 105
Joined: Sat Nov 15, 2003 4:07 am
Location: Hertfordshire, UK

Setting Cookies

Post by lazersam »

Hi all

I want to place cookies on visits to my affiliate sites. The cookies should be set by my script on my server but the visitiors are calling on my affiliate's sites that are not connected to mine!

So, my question is... can I set a cookie on a users computer when they are not visiting my site? I think it can be done if the site they are on calls a image file(?) and this could trigger my script? Anyone know how this is done?

Thanks.

Lawrence.
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

eh? Not 100% sure what you mean but when you mention affiliates = different domains?

You can only access you domain's cookies, no one else's.

-Nay
User avatar
lazersam
Forum Contributor
Posts: 105
Joined: Sat Nov 15, 2003 4:07 am
Location: Hertfordshire, UK

Post by lazersam »

I am going to run an affiliate program. Affiliates can advertise my products on their site (different domain to mine).

I want to be able to place a cookie on their visitor's computer when their visitors hit the affiliates page.

I do not wish to access any cookies just set them :)

Regards

Lawrence.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

lazersam wrote:
I do not wish to access any cookies just set them :)
I have to ask, what is the point in setting a cookie and then not accessing it?

Actually, what you are trying to do is quite easy, however I also consider it to be the biggest misuse of cookies, and it completely goes against the privacy nature of cookies as most users understand them.

If you show me an accurate P3P file that will accompany your intended cookie then I'll show you how to do it.
User avatar
lazersam
Forum Contributor
Posts: 105
Joined: Sat Nov 15, 2003 4:07 am
Location: Hertfordshire, UK

Post by lazersam »

Hi redmonkey
I didnt realise this was a misuse of cookies. I only want to tag the visitor with my affiliates ID so I can credit my affiliate should their visitor buy my products.

I will be accessing these cookies should the visitor come to my sales site.

Whats a p3p file?

Regards

Lawrence.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Not 100% sure, but this would qualify under 3rd part cookies. And if so, have in mind that alot of users have the "Ignore 3rd part cookies" option turned on in their browsers, firewalls, 3rd part protection software etc.

---

Just shooting another idea on the subject:

You can make a php script an image, and inside the code handling that add database functions.
If you have access to a database, you can collect user-ip/afil-sitename and so forth with the image, before displaying it, and insert that info into the database. Can be used to count hits, and depending on how much (and what) information you are to use in your cookie perhaps more.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

umm..

have them send their users to 'http://www.yoursite.com/aff.php?id=theirid'

and then on aff.php:

Code: Select all

<?php
//connect to DB
$id = $_GET['id'];
$sql = "UPDATE `table` SET `in` = in+1 WHERE `id` = '$id'";
mysql_query($sql) or die("Error in updating...");
header("location:index.php");
?>

no need for cookies..
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

JAM is spot on with that idea, that is exactly how it works.

A P3P file is essentially an xml file associated with the cookie which contains various bits of info on how you use the cookie and the type of info that is stored in it.

Cookies of this nature do qualify as 3rd party and although many users reject 3rd party cookies many do not.
Post Reply