One of my clients, a membership-based education resources site, has asked if there is a way to allow non-members to see members-only content but only when following a link shared on Facebook or on Pinterest and, possibly, Twitter.

I know there are ways to reveal a referrer but I'm not sure how reliable those are? Or even if JS or PHP is the best or even the only way to handle this feature?

Any known / tested alternatives to doing this sort of thing?

1 Answer 1


Preventing link sharing is dificult and indeed referrer is not 100% secure too.

You could include some code in the url that is posted to these websites. On the landing page for that url, you could fetch the code from the segment and get the entry with that code and serve the content without checking for membership.

  • The client isn't all that concerned about link sharing and I'd prefer to avoid adding query strings or other bits to the URL since it will be the users who will be sharing the content and with page widgets, bookmarklets or just plain old copy-and-pasting... probably not too viable of a solution. Nov 24, 2013 at 19:12
  • 1
    Also, GDMac, when you say "is not 100% secure" are you just saying not 100% reliable in terms of being able to get the referrer? Nov 24, 2013 at 19:13
  • 1
    Nope, not about being able to get the correct one, about spoofing. with cURL and other simple tools, someone can forge the referrer part that is being sent to your server. en.wikipedia.org/wiki/Referer_spoofing
    – GDmac
    Nov 25, 2013 at 10:12
  • 1
    a unique promo code in (or added to) the url has several benefits. being able to setup, debug, fix, track, timeframe these downloads without interfering with regular visitors/customers
    – GDmac
    Nov 25, 2013 at 10:28
  • GDmac is absolutely right - you can replace referrer use browser ext. also. All browsers have this option. And the same way many users can just automatically cleanup they referrer, so they will come to your site w/o referrer (most of proxy / anti-trace ext. is to this).
    – Max Lazar
    Nov 26, 2013 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.