fix SessionRegenerateID should release old SessionStore and release new SessionStore in router.go
Showing
2 changed files
with
5 additions
and
2 deletions
| ... | @@ -165,7 +165,7 @@ func (c *Controller) RenderBytes() ([]byte, error) { | ... | @@ -165,7 +165,7 @@ func (c *Controller) RenderBytes() ([]byte, error) { |
| 165 | 165 | ||
| 166 | if c.LayoutSections != nil { | 166 | if c.LayoutSections != nil { |
| 167 | for sectionName, sectionTpl := range c.LayoutSections { | 167 | for sectionName, sectionTpl := range c.LayoutSections { |
| 168 | if (sectionTpl == "") { | 168 | if sectionTpl == "" { |
| 169 | c.Data[sectionName] = "" | 169 | c.Data[sectionName] = "" |
| 170 | continue | 170 | continue |
| 171 | } | 171 | } |
| ... | @@ -391,6 +391,7 @@ func (c *Controller) DelSession(name interface{}) { | ... | @@ -391,6 +391,7 @@ func (c *Controller) DelSession(name interface{}) { |
| 391 | // SessionRegenerateID regenerates session id for this session. | 391 | // SessionRegenerateID regenerates session id for this session. |
| 392 | // the session data have no changes. | 392 | // the session data have no changes. |
| 393 | func (c *Controller) SessionRegenerateID() { | 393 | func (c *Controller) SessionRegenerateID() { |
| 394 | c.CruSession.SessionRelease(c.Ctx.ResponseWriter) | ||
| 394 | c.CruSession = GlobalSessions.SessionRegenerateId(c.Ctx.ResponseWriter, c.Ctx.Request) | 395 | c.CruSession = GlobalSessions.SessionRegenerateId(c.Ctx.ResponseWriter, c.Ctx.Request) |
| 395 | c.Ctx.Input.CruSession = c.CruSession | 396 | c.Ctx.Input.CruSession = c.CruSession |
| 396 | } | 397 | } | ... | ... |
| ... | @@ -529,7 +529,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -529,7 +529,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 529 | // session init | 529 | // session init |
| 530 | if SessionOn { | 530 | if SessionOn { |
| 531 | context.Input.CruSession = GlobalSessions.SessionStart(w, r) | 531 | context.Input.CruSession = GlobalSessions.SessionStart(w, r) |
| 532 | defer context.Input.CruSession.SessionRelease(w) | 532 | defer func() { |
| 533 | context.Input.CruSession.SessionRelease(w) | ||
| 534 | }() | ||
| 533 | } | 535 | } |
| 534 | 536 | ||
| 535 | if !utils.InSlice(strings.ToLower(r.Method), HTTPMETHOD) { | 537 | if !utils.InSlice(strings.ToLower(r.Method), HTTPMETHOD) { | ... | ... |
-
Please register or sign in to post a comment