How to bypass third party cookies in C#? Now cookies are set with Response.Cookies.Append and cookieOptions like this:
Response.Cookies.Append("SomeCookie", "SomeValue", cookieOptions);
There is an instructions how to work around the third-party cookies at developer.chrome.com/docs/privacy-sandbox/chips/ - but this Partitioned property is not allowed in cookieOptions class. Is there any way to set custom keys-values for cookie using Response.Cookies.Append ?
As it is not yet supported in dot net, you can just append the Partitioned
property to the Path option. For example:
Response.Cookies.Append("X-Access-Token", accessToken, new CookieOptions()
{
HttpOnly = true,
Secure = true,
SameSite = SameSiteMode.None,
Path = "/; samesite=None; Partitioned"
});
This code also includes a fix to ensure the option samesite=None
is outputted into the cookie.