From 27e21d2685b33d995e3e6e79fd6d9e5c572fcf5b Mon Sep 17 00:00:00 2001 From: Gerasimos Maropoulos Date: Sun, 4 Sep 2016 22:09:54 +0300 Subject: [PATCH] (from previous commit) fix sessions init when UseDatabaseDB before session manager --- iris.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/iris.go b/iris.go index c0385a0a..c933612c 100644 --- a/iris.go +++ b/iris.go @@ -232,14 +232,17 @@ func New(cfg ...config.Iris) *Framework { return s } -func (s *Framework) initialize() { - +func (s *Framework) initSessions() { // set the sessions - if s.Config.Sessions.Cookie != "" { + if s.sessions == nil && s.Config.Sessions.Cookie != "" { //set the session manager s.sessions = fasthttpSessions.New(fasthttpSessions.Config(s.Config.Sessions)) } +} +func (s *Framework) initialize() { + + s.initSessions() // prepare the response engines, if no response engines setted for the default content-types // then add them @@ -600,6 +603,9 @@ func UseSessionDB(db sessions.Database) { // // Note: Don't worry if no session database is registered, your context.Session will continue to work. func (s *Framework) UseSessionDB(db sessions.Database) { + if s.sessions == nil { + s.initSessions() + } s.sessions.UseDatabase(db) }