How to track a purchase from a client by cookie?

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
bigjl
Forum Newbie
Posts: 15
Joined: Fri Jan 13, 2006 11:15 am

How to track a purchase from a client by cookie?

Post by bigjl »

I know cookie can store some information on client machine and it will automatically pop up client's details when the client relog the system.
I tried to think over the way that cookie can access outter websites and get information whether the client has made a purchase or not, but couldnt find a sulotion.
I dont understand how they track a client till the client makes a purchase, even the client makes the purchase the next time with a quote number.
Any of you guys know how the affiliate program tracking work?
Please help me.
Thank you very much
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Re: How to track a purchase from a client by cookie?

Post by shiznatix »

your question does not make much sence. from what I understood there are 2 websites abc.com and xyz.com . Someone buys something from abc.com and it saves a cookie on their computer and then you want xyz.com to be able to read that cookie? Thats impossible (and would be a HUGE security issue if it was possible).

If you ment that you just want to be able to use a cookie and read the information on the same website then look at setcookie() and use the $_COOKIE super global.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: How to track a purchase from a client by cookie?

Post by onion2k »

shiznatix wrote:your question does not make much sence. from what I understood there are 2 websites abc.com and xyz.com . Someone buys something from abc.com and it saves a cookie on their computer and then you want xyz.com to be able to read that cookie? Thats impossible (and would be a HUGE security issue if it was possible).
It's not impossible if you control both the domains. You can get the cookie value from abc.com by setting up a series of forwarders. You simply create a page on abc.com that, when the user hits it, takes the value of the cookie and appends it to a URL as a GET variable, and forwards the user again.. eg

1. User arrives at xyz.com with a cookie set for abc.com.
2. Forward the user to abc.com/cookie.php
3. cookie.php takes the abc.com cookie value and sticks it on the end of index.php .. eg index.php?abccookie=sdfkjnsjkdnfunidviv
4. cookie.php then forwards the user to xyz.com/index.php?abccookie=sdfkjnsjkdnfunidviv

Ta da! xyz.com knows what the value of the cookie set at abc.com is. But you need to control both domains, and it'll only work for stuff where the cookie value doesn't need to be secure.
bigjl
Forum Newbie
Posts: 15
Joined: Fri Jan 13, 2006 11:15 am

Re: How to track a purchase from a client by cookie?

Post by bigjl »

onion2k wrote:
shiznatix wrote:your question does not make much sence. from what I understood there are 2 websites abc.com and xyz.com . Someone buys something from abc.com and it saves a cookie on their computer and then you want xyz.com to be able to read that cookie? Thats impossible (and would be a HUGE security issue if it was possible).
It's not impossible if you control both the domains. You can get the cookie value from abc.com by setting up a series of forwarders. You simply create a page on abc.com that, when the user hits it, takes the value of the cookie and appends it to a URL as a GET variable, and forwards the user again.. eg

1. User arrives at xyz.com with a cookie set for abc.com.
2. Forward the user to abc.com/cookie.php
3. cookie.php takes the abc.com cookie value and sticks it on the end of index.php .. eg index.php?abccookie=sdfkjnsjkdnfunidviv
4. cookie.php then forwards the user to xyz.com/index.php?abccookie=sdfkjnsjkdnfunidviv

Ta da! xyz.com knows what the value of the cookie set at abc.com is. But you need to control both domains, and it'll only work for stuff where the cookie value doesn't need to be secure.
Ok. let me put it straight.
There are 3 websites out there.
abc.com is affiliate website contains ads
my.com is my website
xyz.com is the website owns the ads which put on abc.com
A client clicks the ads on abc.com.
The link points to my.com to store some details of the client.
Then the link redirect to xyz.com.
I need to track all routine that the client takes and need to know whether the client has made a purchase on xyz.com.

Will that be possible?
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

If all the sites are on the same server:

Give the user a unique token at purchase by writing it to a query string and in a db
When they get to the next site check the token vs. db
If it is write the token to a cookie/session for that site.

???
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You can't read cookie data from another domain (XSS aside). So unless they tell you by sending the user or a request back to a url or some other communication, you're out of luck.
bigjl
Forum Newbie
Posts: 15
Joined: Fri Jan 13, 2006 11:15 am

Post by bigjl »

feyd wrote:You can't read cookie data from another domain (XSS aside). So unless they tell you by sending the user or a request back to a url or some other communication, you're out of luck.
So that means it is not possible to build a cookie cross 3 websites. right?
There has to be a intergration between mysite and xyz.com.right?
But how those affiliate program tracking system work? Any of you guys knows?
bigjl
Forum Newbie
Posts: 15
Joined: Fri Jan 13, 2006 11:15 am

Post by bigjl »

I just came up with an idea that I can put some code inside xyz.com and when a client visit to the certain page with my code in it. My code can send something back to my.com. That means i need to control the cookie through javascript. right?
Can i do that?
Post Reply