asp.netchips

Implementing CHIPS cookies in ASP.NET MVC 5


Chrome is starting to block 3rd party cookies soon, starting Jan 2024 with 1% of users. One use case for 3rd party cookies is embedding 3rd party content through an "iframe". It will still be supported through Cookies Having Independent Partitioned State (CHIPS) per Google.

https://developers.google.com/privacy-sandbox/3pcd/chips

All needed is adding the new cookie attribute called "partitioned"

Set-Cookie: __Host-name=value; Secure; Path=/; SameSite=None; Partitioned;

I'd like to be able to configure this in web.config file (just like the SameSite change introduced a few years ago) instead of dealing with HttpCookie objects etc. But, I haven't seen any update in ASP.NET to support this, nor I'm aware of any guidance from Microsoft yet.

Is it because this is still considered experimental? Any guidance you are aware of from Microsoft?


Solution

  • Try something like this:

    <rewrite>
    <outboundRules>
        <clear/>
        <rule name="Partitioned">
            <match serverVariable="RESPONSE_Set-Cookie" pattern=".*"/>
            <action type="Rewrite" value="{R:0}; Partitioned;"/>
        </rule>
    </outboundRules>
    

    reference: https://www.petefreitag.com/blog/samesite-cookies-iis/