# Solved: Keeping track of previous page in PHP - Use HTTPReferer???



## r3drock3t88 (Jan 13, 2007)

Hello all,

I have been trying for days now to have a variable take note of the previous page someone would have been at, then after they click on a link, have them go back to that previous page. This is very useful for my situation, which is irrelevant for my question at hand...

Basically, I have seen many many many forums saying how horrible it is to use

" $_SERVER['HTTP_REFERER']);"

on your website in order to keep track of the previous page. There are apparently many security holes, and also the fact that it may or may not be enabled on that users browser.

The problem is, that is the only thing I have found that is capable of keeping track of the previous page! Is there any other way? How do the big websites do it?

Thank you all in advance for any help,

- Sam


----------



## MMJ (Oct 15, 2006)

Never heard of any security holes and it is usually enabled. Just don't use it as if it is 100% dependable all the time.

Other options:
Storing the last page in a GET variable (example: ?from=products.php)
Storing the last page in a cookie.

All 3 of these options, while usually dependable, are very easy for the user to disable, spoof, etc.


----------



## Anthony:-P (Nov 24, 2006)

Another alternative would be to store the "current" and "previous" pages in a session 


Thanks,
Anthony :up:


----------



## MMJ (Oct 15, 2006)

Anthony:-P said:


> Another alternative would be to store the "current" and "previous" pages in a session
> 
> Thanks,
> Anthony :up:


Yep.

Which is pretty much what I meant when I mentioned cookies.


----------



## Big-K (Nov 22, 2003)

It's only a security issue if you're using the referrer to determine if someone is allowed to view a specific page (like in a form where you enter information and get something at the end, someone could spoof the referrer and bypass the whole form). If it's just for use in a back link, HTTP_REFERRER will be just fine.


----------



## r3drock3t88 (Jan 13, 2007)

Thank you all for your input! It is much appreciated, that's why I come to this site .

Have a good one.


----------

