I am trying to handle session in microservice application using spring session and I am storing session in mysql database.
here is my pom.xml
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId></dependency>
This is where I am specifing database configuration and some spring session attributes. I am setting session time to 24 hours and I am specifying spring.session.jdbc.initialize-schema to always so that Spring will create the required tables for us.
spring:
session:
store-type: jdbc
jdbc.initialize-schema: always
server:
servlet:
session:
timeout: 86400
This is how I am creating session
HttpSession session = request.getSession();
session.setAttribute("email", "abc@gmail.com");
Till here everything works fine and session is getting created for 24 hours in database table, but problem here is, sessions are getting cleared automatically before specified time.
I have searched a lot but still not able to fix this issue. Am I missing any configuration here or do I need to add anything extra to work this as expected ?