Show Navigation


This plugin provides spring-session support in grails application.

Owner: jeetmp3 | 2.0.0-RC1 | Mar 31, 2016 | Package | Issues | Source | License: Apache-2.0

dependencies {
    compile 'org.grails.plugins:spring-session:2.0.0-RC1'


Grails 3

The 2.X version of the plugin is compatible only with grails 3.

Grails 2.x Documentation


This plugin provides spring-session support in grails application. SpringSession provides nice features:

  • HttpSession
    • Clustered Sessions
    • Multiple Browser Sessions
    • RESTful APIs
  • WebSocket

SpringSession uses Redis to persist the HTTP Sessions. You can find official documentation for Spring Session project here:

Currently this plugin provides support for HttpSession only. WebSocket support will be added in further release.


Just add a plugin in BuildConfig.groovy.

plugins {
    runtime ":spring-session:1.2"

Note: Redis must be installed on your machine.


1. Redis Configuration

Default configuration will lookup Redis server on your localhost port 6379. To override default configuration add below code in Config.groovy

springsession.redis.connectionFactory.hostName = "<redis server ip>"
springsession.redis.connectionFactory.port = 6379
springsession.redis.connectionFactory.password = "<password>"
springsession.redis.connectionFactory.timeout = 2000
springsession.redis.connectionFactory.usePool = true
springsession.redis.connectionFactory.dbIndex = 0

2. Change Session Strategy Configuration

Default session strategy is Cookie based and session cookie name is SESSION You can override the default session strategy


This will enable HTTP Header based session strategy. Default token name is x-auth-token you can override this

springsession.strategy.token.headerName = "new token name"

To change default cookie name add below configuration."Your Cookie name"

(Note: Property is no longer available in version 1.1 and higher)

3. Configure redis sentinel

springsession.redis.sentinel.master="<Sentinel master name>"
springsession.redis.sentinel.nodes=[[host: "hostname", port: xxxx], [host: "another host", port: xxxx]]
springsession.redis.sentinel.password="Sentinel password"

4. Enable update mutable objects in session

By default spring session doesn't update mutable object value stored in session. You can override this behaviour by setting below property to true. By default this value is false.

springsession.allow.persist.mutable = true

Version Support

  • Grails 2.4 +
  • Redis 2.8 +