11

Can these properties used to disable the session mechanism completely?

server.session.persistent=false
server.session.timeout=0

If not, how to do this?

Hemant
  • 1,403
  • 2
  • 11
  • 21
CelinHC
  • 1,857
  • 2
  • 27
  • 36
  • What do you mean by "disable session[s]"? What sort of behaviour change are you expecting comparing to the default "out-of-the-box" Spring Boot app? – kryger Jan 26 '16 at 14:21
  • no those parameters will not disable sessions. closest answer is here https://stackoverflow.com/questions/2255814/can-i-turn-off-the-httpsession-in-web-xml which says we can not disable sessions in tomcat. – ozkanpakdil Oct 05 '19 at 11:17

3 Answers3

2

had success with setting it to an empty set: server.servlet.session.tracking-modes=

@see https://docs.spring.io/spring-boot/docs/2.2.0.RELEASE/reference/htmlsingle/#server-properties

@see https://docs.spring.io/spring-boot/2.2.0.RELEASE/current/api/org/springframework/boot/web/servlet/server/Session.html#setTrackingModes-java.util.Set-

166_MMX
  • 590
  • 5
  • 18
1

try type in application.properties:

spring.session.store-type=none

...to disable spring session

See: https://docs.spring.io/spring-boot/docs/2.2.0.RELEASE/reference/htmlsingle/#boot-features-session

Vagner Nogueira
  • 131
  • 2
  • 5
-1

A couple of notes for posterity:

  1. Persistent sessions are sessions that survive server restarts, thus, when you enable that, Spring will serialize and store your session somewhere to load it later.
  2. For a complete discussion on how to reliably disable sessions, please see this post: Can I turn off the HttpSession in web.xml?
MuratOzkan
  • 2,599
  • 13
  • 25