Share via

CookiePolicyOptions interfering with localization cookie in Blazor server-side app

Ivan-Mark Debono 1 Reputation point
2022-08-31T16:01:26.77+00:00

I have a Blazor server-side and I have the following cookie policy options set up:

services.Configure<CookiePolicyOptions>(options =>  
{  
    options.CheckConsentNeeded = context => true;  
    options.MinimumSameSitePolicy = SameSiteMode.None;  
});  

The app also implements cookie localization as described in this MS article.

However, the problem is that with the above policy options, the localization cookie is not being created.

If I change the policy options to (or remove them completely):

services.Configure<CookiePolicyOptions>(options =>  
{  
    options.MinimumSameSitePolicy = SameSiteMode.Unspecified;  
});  

The localization cookie is created and localization works as expected. So the original options are interfering with the localization cookie.

A sample Blazor project experiencing this problem is found in this GitHub repo.

Is there a solution/workaround in which I have the original cookie policy options (required for consent) and also a working localization cookie?

Developer technologies | .NET | Blazor

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.