Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to know where the user is coming from when he uses the back button?

Tags:

http-referer

For example,

if user goes to google -> example.com -> newwebsite.com

If he goes back to example.com, the http-referrer page will still be google.com

How can I detect that he went to newwebsite.com

like image 585
chris Avatar asked Sep 16 '25 00:09

chris


1 Answers

I believe that the back button will send the HTTP headers that were sent to the site the first time around, since it's not really a new visit.

Say you displayed an error page if the user's http-referrer was newwebsite.com. The first time they visited, they would get your site. If they went to newwebsite.com, and then hit back (meaning they wanted to go back in time, through their browser history, not load the page again with new headers), then they would get an error page, and the nature of the back button would be defeated. I don't know if this inspires that behavior or not, it just makes sense to me that way.

Maybe it's possible, but it would be entirely browser-dependent. Why do you need this functionality, anyway? Newwebsite isn't referring the user to your website at all, there's no connection between the two at all--it just happens to be the last page that the user visited.

like image 73
Carson Myers Avatar answered Sep 17 '25 18:09

Carson Myers