Welcome to WebmasterWorld Guest from 174.129.151.95

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

how to get referrer from a javascript redirect?

get the referrer url from javascript redirects

   
12:06 am on Sep 10, 2008 (gmt 0)

10+ Year Member



I'm trying to limit access to a page to people coming from a specific domain.
However, that domain is using
<script>window.location='http://www.mysite.com'</script>
to do the redirect and i'm using
if (($_SERVER['HTTP_REFERER'] = "http://www.theirsite.com")
to check it- the result, referrer is blank...

Any ideas how to get the referrer even if its a javascript redirect?

5:11 am on Sep 15, 2008 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



Don't know if you can. The referrer cannot always be trusted, anyway. Have you found a way around this problem?
2:30 pm on Sep 15, 2008 (gmt 0)

10+ Year Member



No, had to check on a variable being present to verify. Not as good, but it works...
2:40 pm on Sep 15, 2008 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



If the referer is going to be set, it should not matter whether the site is doing a JavaScript redirect, a server-side redirect or the user is clicking a link in the normal way. (?) If the referer is not set, it is likely to be another reason - and out of your control.

Just to note, you only have a single equals (assignment) rather than a comparison (double equals), but then your code would always execute...

if (($_SERVER['HTTP_REFERER'] = "http://www.theirsite.com")