当前位置: 代码迷 >> 综合 >> Springboot JSESSIONID 设置 SameSite 属性为 NONE
  详细解决方案

Springboot JSESSIONID 设置 SameSite 属性为 NONE

热度:14   发布时间:2023-12-11 15:58:10.0

修复:This set-cookie didn't specify a "SameSite" attribute and was defaulted to "SameSite=Lax" and broke the same rules specified in the SameSiteLax value

application.yml

server:servlet:session:cookie:secure: true
@Configuration
public class MvcConfig implements WebMvcConfigurer {/*** 设置Cookie的SameSite*/@Beanpublic TomcatContextCustomizer sameSiteCookiesConfig() {return context -> {final Rfc6265CookieProcessor cookieProcessor = new Rfc6265CookieProcessor();cookieProcessor.setSameSiteCookies(SameSiteCookies.NONE.getValue());context.setCookieProcessor(cookieProcessor);};}}

我的Springboot 版本

<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.2.2.RELEASE</version><relativePath/>
</parent>