Search code examples
phphttpcookie

PHP or Javascript to read clickbank hoplink cookie?


I need to write a PHP or javascript that can read the clickbank cookie that's set when a user has clicked on one of my affiliate's hoplinks prior to reaching any of my sales pages.

How can one do this?

Here's my example:

I have a main salespage that I direct my referred users to (users who already know me and were not referred by an affiliate). It does not use ClickBank as a payment gateway.

I also have a salespage specifically for clickbank referrals. It uses ClickBank to clear transactions.

I would like to add script to MY salespage that will check to see if the user has an active cookie that denotes they've been referred to my product page by a hoplink. If so, I want to redirect them to the clickbank sales page for my product.

Any help much appreciated.


Solution

  • You can't read cookies for a domain that isn't yours. So if ClickBank sets cookies for clickbank.com then you can't access them from yourdomain.com.

    If you share part of a domain then you can. Eg. clickbank.example.com and yoursite.example.com the cookies could be set to example.com and be read by both. However clickbank would have to make this change so I think you're probably out of luck.