1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-12 09:51:01 +00:00
1. session move from astaxie/session to beego/session
2. support 4 type session
This commit is contained in:
astaxie
2013-04-05 23:50:53 +08:00
parent 69f40ad18a
commit 2573696860
9 changed files with 645 additions and 31 deletions

View File

@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"encoding/xml"
"github.com/astaxie/session"
"github.com/astaxie/beego/session"
"html/template"
"io/ioutil"
"net/http"
@ -51,7 +51,6 @@ func (c *Controller) Prepare() {
}
func (c *Controller) Finish() {
}
func (c *Controller) Get() {
@ -82,21 +81,6 @@ func (c *Controller) Options() {
http.Error(c.Ctx.ResponseWriter, "Method Not Allowed", 405)
}
func (c *Controller) SetSession(name string, value interface{}) {
ss := c.StartSession()
ss.Set(name, value)
}
func (c *Controller) GetSession(name string) interface{} {
ss := c.StartSession()
return ss.Get(name)
}
func (c *Controller) DelSession(name string) {
ss := c.StartSession()
ss.Delete(name)
}
func (c *Controller) Render() error {
rb, err := c.RenderBytes()
@ -190,7 +174,25 @@ func (c *Controller) Input() url.Values {
return c.Ctx.Request.Form
}
func (c *Controller) StartSession() (sess session.Session) {
func (c *Controller) StartSession() (sess session.SessionStore) {
sess = GlobalSessions.SessionStart(c.Ctx.ResponseWriter, c.Ctx.Request)
return
}
func (c *Controller) SetSession(name string, value interface{}) {
ss := c.StartSession()
defer ss.SessionRelease()
ss.Set(name, value)
}
func (c *Controller) GetSession(name string) interface{} {
ss := c.StartSession()
defer ss.SessionRelease()
return ss.Get(name)
}
func (c *Controller) DelSession(name string) {
ss := c.StartSession()
defer ss.SessionRelease()
ss.Delete(name)
}