Use redis to store the sessions
This commit is contained in:
@ -15,7 +15,9 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/alexedwards/scs/redisstore"
|
||||
"github.com/alexedwards/scs/v2"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
)
|
||||
|
||||
const portNumber = ":8080"
|
||||
@ -80,7 +82,16 @@ func run() (*driver.DB, error) {
|
||||
// change this to true when in production
|
||||
app.InProduction = *inProduction
|
||||
|
||||
// Establish connection pool to Redis.
|
||||
pool := &redis.Pool{
|
||||
MaxIdle: 10,
|
||||
Dial: func() (redis.Conn, error) {
|
||||
return redis.Dial("tcp", "localhost:6379")
|
||||
},
|
||||
}
|
||||
|
||||
session = scs.New()
|
||||
session.Store = redisstore.New(pool)
|
||||
session.Lifetime = 24 * time.Hour
|
||||
session.Cookie.Persist = true
|
||||
session.Cookie.SameSite = http.SameSiteLaxMode
|
||||
|
Reference in New Issue
Block a user