Link to home
Start Free TrialLog in
Avatar of TheGtrsR1
TheGtrsR1

asked on

$_SERVER['HTTP_REFERER'] doesn't work in IE

I'm using $page = basename($_SERVER['HTTP_REFERER']) to find the page the user came from so it can be stored in a database. This works great in FF, but when I go to use IE it doesn't work at all, IE doesn't send the URL like FF does. I understand that HTTP_REFERER is based on what the user agent sends, but why doesn't  IE work with this?  Or is there a better way to get the page they came from as a php variable? Sorry, I know this is short if the question isn't clear let me know and I'll try and say it differently. Thanks.
Avatar of LinuxNubb
LinuxNubb
Flag of United States of America image

Directly from php.net

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


And from http://www.netregistry.com.au/support/scripting/PHP/php_faq.html#3

http_referer function is not working
The http_referer function does not work with Internet Explorer 6. This is a result of a security patch performed by Microsoft to overcome some weaknesses. The function works fine when run with any other web browser e.g. Mozilla.
Avatar of TheGtrsR1
TheGtrsR1

ASKER

Thanks for the info from netregistry...I had not found that one. If I can't do it with HTTP_REFERER...do you know of another way to get the page that the user was referred from and be able to use that variable in PHP? I can do it in javascript, but the problem was that I can't get that variable to PHP directly. I tried using a cookie, but it didn't update every time. I had to refresh the page to get the current cookie.

Any ideas are appreciated.
I'm not sure how else you'll do it.  It's another one of those great php mysteries!
ASKER CERTIFIED SOLUTION
Avatar of Jay-Shahj
Jay-Shahj

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial