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 - 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.

Recommended Answers

All 2 Replies


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://localhost:8000/

You'll get:

GET / HTTP/1.1
User-Agent: curl/7.35.0
Host: localhost:8000
Accept: */*

More information here:

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, learning, and sharing knowledge.