1. Overview

In this article, we will learn how to secure session cookies in spring boot. Spring boot’s server.session.cookie.secure configurable is available using that we can secure spring boot session cookies.

2. Configuration

2.1 application.properties

set server.session.cookie.secure configuration as true in application.properties file and make sure that application.properties available inside resources directory.

server.session.cookie.secure=true

2.2 application.yml

We can set server.session.cookie.secure using application.yml syntax.

server:
  session:
    cookie:
      secure: true

2.3 Command Option

Using command line server.session.cookie.secure as command line while starting spring boot application.

java -jar spring-boot-example-1.0-SNAPSHOT.jar --server.session.cookie.secure=true

 

Output:

spring boot secure session cookies

spring boot secure session cookies

 

3. References

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *