我在IIS中尝试过samesite cookie。但是没有运气。如何在IIS中使用它?顺便说一句,我正在使用Windows Server 2012 R2。
配置:
<sessionState timeout="60" cookieSameSite="None" />
<httpCookies sameSite="None"/>
这通常在应用程序的启动和初始化中进行管理。
在IIS(而不是您的应用程序)中执行此操作的一种方法是,添加出站重写规则以附加SameSite=None
到响应中发送的cookie。
范例Web.config
:
<system.webServer>
<rewrite>
<outboundRules>
<clear />
<rule name="Add SameSite" preCondition="No SameSite">
<match serverVariable="RESPONSE_Set_Cookie" pattern=".*" negate="false" />
<action type="Rewrite" value="{R:0}; SameSite=None" />
</rule>
<preConditions>
<preCondition name="No SameSite">
<add input="{RESPONSE_Set_Cookie}" pattern="." />
<add input="{RESPONSE_Set_Cookie}" pattern="; SameSite=None" negate="true" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句