When is the SessionId of Shiro set to the client?

< H2 > scene < / H2 >

when using Cors for cross-domain login, everything is fine, but the client does not add SessionId ( Cookie inside), so it is not clear what happened.

call js code:

<!--cors -->
<filter>
  <filter-name>customCorsFilterConfig</filter-name>
  <filter-class>CustomCorsFilterConfig</filter-class>
</filter>
<filter-mapping>
  <filter-name>customCorsFilterConfig</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

however, after the normal request ends, SessionId is not set in cookie on the client side. Why? "(_;)"

Apr.05,2021

shiro registers things like filters to do this, so session id is not web container in charge.


now the problem is solved, or the client request is not set correctly. As long as you need to bring / return authentication information , you must add the parameter credentials .

the request now looks something like this:

fetch('http://localhost:8089/test/setSession', {
    credentials: "include"
})
    .then(res => res.json())
    .then(json => console.log(json))
Menu