Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if browser accepts cookies

Is there a way that I can check if the browser will allow cookies.

Request.Browser.Cookies 

Doesn't work when cookies are disabled. It says the browser can support them.

The only other thing I can think of is to try to set a test cookie and then check to see if it ever got set.

Is there anyway to make sure cookies are actually enabled.

like image 980
Dietpixel Avatar asked Aug 06 '11 03:08

Dietpixel


People also ask

Can I accept cookies on my browser?

Click 'Tools' (the gear icon) in the browser toolbar. Choose Internet Options. Click the Privacy tab, and then, under Settings, move the slider to the top to block all cookies or to the bottom to allow all cookies, and then click OK.

Do I have cookies disabled in my browser?

Open Chrome. Go to More menu > Settings > Site settings > Cookies. You'll find the More menu icon in the top-right corner. Make sure cookies are turned on.

Does my browser allow third-party cookies?

Open Chrome preferences click on Settings, then Show Advanced Settings. Under Privacy, click on Content Settings. Make sure “Block third-party cookies and site data” is not checked. If your browser is not listed above, please refer to your browser's help pages.

Can any site read any cookie?

A cookie can only be read by the site that created it Cookies are extremely important to security and privacy, and it would be a disaster if one website was able to read cookies from another website, so a lot of care is taken by browser developers to ensure that cookies can only be read by the site that created them.


2 Answers

According to MSDN there is no way to determine cookies is allowed or disabled by user. The only way to find it out is through writing it and then reading it.

Check the section "Determining Whether a Browser Accepts Cookies" here.

It also has examples which show how to read and write cookies, and states:

The Cookies property does not indicate whether cookies are enabled. It indicates only whether the current browser inherently supports cookies.

like image 149
Deepesh Avatar answered Oct 02 '22 14:10

Deepesh


I don't know any way to do it in asp.NET. All you can do is to create a cookie and try to read it in the postback.
You can see example of how to do it (this is in vb.NET but I'm sure you can find in google many other examples and in C#): http://forums.asp.net/t/1044823.aspx

like image 36
Naor Avatar answered Oct 02 '22 14:10

Naor