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.

有帮助吗?

解决方案

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.

其他提示

I know how the clickbank works and he tried to explain something different.

When affiliates sending visitors to his sale page, it adds the affiliate id at the end (fx mysite.com/?id=nick)

People can also come to his sale page directly(like mysite.com) simply typing his url. So he wants to check if the visitor come directly or with an affilate link.

So you have to answer first : -Are you saving cookies at visitor browser(if not, you don't have to worry about your problem)? -If not, then @Robert answer is going to help you...

@Balir McMillan summed it up pretty well, cookies are locked to the domain that set it, that includes sub domains etc.

I am not fully shore how ClickBank works but it seems to me that you want to check to make sure that the referral was from a clickbank hop.

What you can do in PHP is check the $_SERVER['HTTP_REFERER'] to check the referrer, but I will tell you this can be faked and should be used with caution

Or you could get the hop variable directly from the URL and redirect to your affiliate sales page.

<?php
if(isset($_GET['hop'])) {
    $cbid = htmlentities($_GET['hop']);
    header('location: affiliatesalespage.php?a='.$cbid);
}
?>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top