From 6e9ba0ea7f014642f62a915d28e6868cd41f1474 Mon Sep 17 00:00:00 2001 From: slene Date: Sat, 11 Jan 2014 17:01:33 +0800 Subject: [PATCH] fix SessionRegenerateID should release old SessionStore and release new SessionStore in router.go --- controller.go | 3 ++- router.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/controller.go b/controller.go index 04352706..342bf06b 100644 --- a/controller.go +++ b/controller.go @@ -165,7 +165,7 @@ func (c *Controller) RenderBytes() ([]byte, error) { if c.LayoutSections != nil { for sectionName, sectionTpl := range c.LayoutSections { - if (sectionTpl == "") { + if sectionTpl == "" { c.Data[sectionName] = "" continue } @@ -391,6 +391,7 @@ func (c *Controller) DelSession(name interface{}) { // SessionRegenerateID regenerates session id for this session. // the session data have no changes. func (c *Controller) SessionRegenerateID() { + c.CruSession.SessionRelease(c.Ctx.ResponseWriter) c.CruSession = GlobalSessions.SessionRegenerateId(c.Ctx.ResponseWriter, c.Ctx.Request) c.Ctx.Input.CruSession = c.CruSession } diff --git a/router.go b/router.go index fce3885b..bb083768 100644 --- a/router.go +++ b/router.go @@ -529,7 +529,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) // session init if SessionOn { context.Input.CruSession = GlobalSessions.SessionStart(w, r) - defer context.Input.CruSession.SessionRelease(w) + defer func() { + context.Input.CruSession.SessionRelease(w) + }() } if !utils.InSlice(strings.ToLower(r.Method), HTTPMETHOD) {