PHP HTTP_REFERER Problem!?

  • Thread starter Thread starter brind9562
  • Start date Start date
B

brind9562

Guest
Hi I am trying to set up a login page for my website. After login I want to redirect my user to the page they came from. Everything is working fine but when the previous page has 2 variables for example http://www.example.com/example.php?ID=1&cmd=2 the user only gets redirected back to http://www.example.com/example.php?ID=1, thus taking off the &cmd=2. Does anyone know why this may be and what I can do to stop it.

Any help will be greatly appreciated.

Thanks
Ben
 
Hey Ben,

First off, I wanted to let you know that using $_SERVER['HTTP_REFERER'] may not be the best method...

PHPs documentation states that:
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

This means that the browser determines the referring url, and it can be changed or spoofed by the end-user... not the most reliable if you ask me.

To capture the query string params, you would use $_SERVER['QUERY_STRING']
 
Back
Top