0

i am trying for this,

i have two pages : http://example.com/first-page and http://example.com/second-page

Here http://example.com/first-page is a simple landing page which has only a captcha to detect bots and http://example.com/second-page is a main page.

So,when a visitor comes from a referrer to first page and the same referrer value should be passed to second page.

Is it possible with JS or PHP?

  • Use tokens. Generate and embed tokens on first page and verify it on second page to get maximum security. You can also check referer header – Sagar V Apr 09 '20 at 13:00

1 Answers1

0

You can put the referrer value into the session array which can be accessed using PHP on any page, as below:

session_start();
$_SESSION['referrer_val'] = $_SERVER['HTTP_REFERER'];

On the second page, you can store the value in a local variable and then unset all global session variables and destroy the session in this manner:

$accessed_refer_val = $_SESSION['referrer_val'];
session_unset();
session_destroy();

These answers give more ways to accomplish this (like POST): PHP Pass variable to next page See also for more information: PHP Sessions | W3Schools

tanmay_garg
  • 377
  • 1
  • 13
  • Hello tanmay_garg,Thanks for your answer,but how can I make the passed referrer value as HTTP_REFERRER on second page? do I want to assign or do something ? – Neela Kanta Apr 09 '20 at 17:09
  • You could assign the http referer to $accessed_referer_val. But that will only change the referer for the php, not the browser. Also, when you implement this in your code, please make sure to avoid the double 'r' typo in REFERRER. – tanmay_garg Apr 10 '20 at 07:57