Question

When request.referer doesn't return anything, does that always mean that the visitor didn't do the request through a link - i.e. she somehow manually entered the requested page's address?

Or are there other cases where request.referer returns nil (granted that the request is successful)?

Was it helpful?

Solution

Short answer: No.

Generally speaking, the referrer - like all other HTTP headers - is user submitted data. User submitted data should not be trusted.

Off the top of my head I can think of these scenarios, where the referrer wouldn't be set without the user having manually entered the URL.

There might well be other cases (fx I am not sure how browsers handle referrers when opening links in new windows).

And then there are the cases where the referrer is set, but no user has entered the address; notably bots - especially the referrer-spamming ones.

OTHER TIPS

I have not verified that but it's always safe not to check nil for blank value but to use blank?

request.referrer.blank?

This ensure the case when it's nil or blank string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top