java(tomcat)如何设置cookie samesite属性

自从Chrome搞了个cookie samesite属性弄了iframe跨域整合站点带来了麻烦,为了恢复cookie不被拦截需要设置cookie samesite属性=None,但发现javax.http.Cookie没有这个接口

要设置只能到tomcat9/conf/context.xml 下<Context>增加:

<CookieProcessor sameSiteCookies="None" />

注:只支持tomcat8/9最新版本

增加后发现还是不得,还得设置cookie secure, 这个javax.http.cookie到有api,但随机的JSESSIONID还得通过在tomcat9/conf/web.xml

<session-config>
        <session-timeout>30</session-timeout>
        <cookie-config>
            <secure>true</secure>
        </cookie-config>
    </session-config>

同时开通https访问!


版权声明:本文为CowBoy1967原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。