How to Check if cookies are enabled or disabled Part 61

  • دعنا نشارك هذا :
ترتيب الدرس : 61
المدة : 00:13:50
التحكم :
Text version of the video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.


All ASP .NET Text Articles

All ASP .NET Slides

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic

Most of the articles on the internet, states we can use Request.Browser.Cookies property to check, if the cookies are enabled or disabled. This is incorrect.
if (Request.Browser.Cookies)
//Cookies Enabled
//Cookies Disabled

Request.Browser.Cookies property is used to check, if the browser supports cookies. Most mordern browsers, support cookies. Irrespective of whether, the cookies are enabled or disabled, if the browser supports cookies, Request.Browser.Cookies always returns true. So use this property to check if the browser supports cookies and not to check if the cookies are enabled or disabled.
if (Request.Browser.Cookies)
//Broswer supports cookies
//Broswer does not supports cookies

So, the next question is, how do we check, if cookies are enabled or disabled?
1. Write a Test Cookie
2. Redirect to the same page
3. Read the Test Cookie
4. If Cookies preseent - Cookies are enabled
5. Else - Cookies are disabled.

To disable cookies in Internet Explorer(IE 9)
1. Click on Tools
2. Select Internet Options
3. Click on the Privacy tab
4. Click the Advanced button, under settings
5. Check Override automatics cookie handling check box
6. Select Block radio button under First Party cookies and Third Party Cookie

The above steps disable cookies, only for the internet zone. If you are testing code on your local machine, and to disable cookies for localhost
1. Run the application
2. Press F12, to open developer tools
3. Then Select, Cache - Disable Cookies

سيتم تفعيل التعليقات قريبا

Sep 23, 2020 07:32:24