Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine if a request was via a browser bookmark/favorite vs a link?

Say I am on a website viewing the homepage at https://whateverxyz.com/index. Then I either

  • (A) click a navigation link in the HTML of the page to https://whateverxyz.com/app1.html
  • (B) click on a browser bookmark to https://whateverxyz.com/app1.html

Can the server tell the difference between whether request was from A or B? Can client-side JavaScript running on app1.html tell the difference?

like image 248
jwl Avatar asked Dec 18 '22 21:12

jwl


2 Answers

Citate from your question:

  • Can the server tell the difference between whether request was from A or B?
  • Can client-side JavaScript running on app1.html tell the difference?

In both cases this is not possible to detect the difference.

What say us official resources?

Citate from RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1)

If the target URI was obtained from a source that does not have its own URI (e.g., input from the user keyboard, or an entry within the user's bookmarks/favorites), the user agent MUST either exclude the Referer field or send it with a value of "about:blank".

The Referer field has the potential to reveal information about the request context or browsing history of the user, which is a privacy concern if the referring resource's identifier reveals personal information (such as an account name) or a resource that is supposed to be confidential (such as behind a firewall or internal to a secured service). Most general-purpose user agents do not send the Referer header field when the referring resource is a local "file" or "data" URI. A user agent MUST NOT send a Referer header field in an unsecured HTTP request if the referring page was received with a secure protocol. See Section 9.4 for additional security considerations.

Read more about it:

  • Referrer Policy
  • HTTP referer

Alternative solution

But something you could do on client side. In the page https://whateverxyz.com/index you could write one listener in JavaScript which detect all clicks on this page links. And on click event you could write the link URL and the time in a cookie, an IndexedDB or a localStorage. Then in the page https://whateverxyz.com/app1.html you have to read this information. In the case if this information is not undefined it is from link and in all other cases it is from bookmark (or may be it was tipped in adress bar, or whatever).

See related questions:

  • In what cases will HTTP_REFERER be empty
  • How to client-side detect when a page is bookmarked?
  • How to detect if a link already is in the user's bookmarks?
  • Is there a way to know if someone has bookmarked your website?
like image 188
Bharata Avatar answered Dec 20 '22 10:12

Bharata


I am afraid, you can not find out! It is only accessible in browsers extensions.

like image 22
Iman Avatar answered Dec 20 '22 10:12

Iman