All,

I have a odd scenerio which I'm looking to resolve - what is the best way in CGI/PERL to detect the referring page - as depending on if the referring page is from http://www.mysites.com/wholesale - I need to display a button on the page that when clicked will be for a $4 item - otherwise the button on the page when clicked will be for an $8 item.

I'm just not sure what currently is the best practice for utilizing in CGI/PERL the HTTP Referrer - I'm open to utilizing JavaScript as well - my main concern is knowing the referrer so that I can pass in the right dollar amount.

Hello,

are you aware that the referrer can be spoofed? Simple test:

  1. open a terminal and type: nc -l 8000
  2. open another terminal and type: curl --verbose --header --referer http://google.com/ http://localhost:8000/

You'll get:

GET / HTTP/1.1
User-Agent: curl/7.35.0
Host: localhost:8000
Accept: */*
Referer: http://google.com/

More information here: https://en.wikipedia.org/wiki/Referer_spoofing

Yes good point - so what is the best way to typicaly handle the situation then I'm trying to remedy as essentially - I have to handle and account for this odd situation in code somehow.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.