How reliable is the Request.Browser.Cookies property in ASP.NET?

The Request.Browser.Cookies attribute (of type bool ) stores information about whether the client browser supports cookies and whether they are enabled.

How reliable is the Request.Browser.Cookies property? Is it guaranteed right? Or am I better off using the redirection method proposed by Software Monkey in this matter ?

Please note: this is not a "reliable cookie" question? . This question is: "Is the information about whether the user supports cookies the browser?"

+4
source share
2 answers

With a revised question, new answer:

The HttpBrowserCapabilitiesBase.Cookies documentation HttpBrowserCapabilitiesBase.Cookies says:

This property does not indicate whether cookies are enabled in the browser only if the browser supports cookies.

It seems to be installed based on user browser discovery and a database of browser capabilities on the server. Thus, it will tell you with confidence whether the browser can store cookies if and only if:

  • The query user agent string is correct.
  • The browser is in the database and the database is correct for the browser.

Condition No. 1 will be broken if the header of the user's HTTP agent has been changed (for example, by developer tools or a proxy server). Condition No. 2 will be violated if the browser is newer than the database, or if there is a defect in the database.

tl; dr version: there is no guarantee, consider this information as "best effort." And, of course, the user could turn off cookies (for example, in "private" viewing mode).


Original answer to another question:

If you want to rely on cookies that you send in response, you always return in the same way, then the answer is: usually, but do not rely on it.

Possible reasons:

  • Non-HTTP cookies can be modified by the client side of the script (and that the script can be entered locally).
  • Browser Error.
  • Use a non-browser for the request (e.g. wget.exe ) that does not process cookies for the user.
  • A proxy server that modifies a request or response.
  • The local clock on the client system, changed to turn off the cookie.
  • User modifies browser cookie storage.
+2
source

I understand that people do not understand the essence of your question. But you seem to doubt the reliability of the method. I mean, I could ask if Request.QueryString is reliable? Will it return all parameters in the request url? and the answer is yes if you do not have any information that contradicts this. So, do you have information that Request.Browser.Cookies is not reliable? As far as I know, this is so. Have you encountered a situation where it does not work correctly?

+1
source

Source: https://habr.com/ru/post/1343347/


All Articles