Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable automatic creation of ".AspNet.Consent" cookie?

ASP.NET Core 2.1

I think this gets set automatically. How do I prevent that?

like image 931
lonix Avatar asked Jul 25 '18 09:07

lonix


1 Answers

Just came across the same issue. My 100% cookie-free website had a cookie, created by ASP.NET Core. As @mark-g pointed out in his comment, it is mainly added to support GDPR: Let users of your web page opt-in/out for the allowance to collect and keep data about them.

In all usual cases I'd recommend to go this route as designed by Microsoft. Keep the ASP.NET cookie and make use of the _CookieConsentPartial.cshtml for all personal data you might want to keep about the users.

In my special case, I have a very simple web page. No data is collected, also not from any third parties. I dont need the cookie consent and the ASP.NET cookie. In this case, can remove this cookie just by commenting out one line:

In Startup.cs comment out the line:

// app.UseCookiePolicy(); No cookies used at all!

Then clear all caches and remove the cookie, reload the page and it is gone.

like image 145
jboi Avatar answered Sep 28 '22 07:09

jboi