spring-framework / org.springframework.web.socket.config.annotation / SockJsServiceRegistration / setSessionCookieNeeded

setSessionCookieNeeded

open fun setSessionCookieNeeded(sessionCookieNeeded: Boolean): SockJsServiceRegistration

The SockJS protocol requires a server to respond to the initial "/info" request from clients with a "cookie_needed" boolean property that indicates whether the use of a JSESSIONID cookie is required for the application to function correctly, e.g. for load balancing or in Java Servlet containers for the use of an HTTP session.

This is especially important for IE 8,9 that support XDomainRequest -- a modified AJAX/XHR -- that can do requests across domains but does not send any cookies. In those cases, the SockJS client prefers the "iframe-htmlfile" transport over "xdr-streaming" in order to be able to send cookies.

The default value is "true" to maximize the chance for applications to work correctly in IE 8,9 with support for cookies (and the JSESSIONID cookie in particular). However, an application can choose to set this to "false" if the use of cookies (and HTTP session) is not required.