Session
package revel
type Session map[string]string
const (
SESSION_ID_KEY = "_ID"
TS_KEY = "_TS"
)
func (s Session) Id() string {
if uuidStr, ok := s[SESSION_ID_KEY]; ok {
return uuidStr
}
uuid, err := simpleuuid.NewTime(time.Now())
if err != nil {
panic(err)
}
s[SESSION_ID_KEY] = uuid.String()
return s[SESSION_ID_KEY]
}
func SessionFilter(c *Controller, fc []Filter) {
c.Session = restoreSession(c.Request.Request)
c.RenderArgs["session"] = c.Session
fc[0](c, fc[1:])
c.SetCookie(c.Session.cookie())
}