Documentation ¶
Index ¶
- func Register(name string, provide Provider)
- type FromMemory
- func (frommemory *FromMemory) SessionDestroy(sid string) error
- func (frommemory *FromMemory) SessionGC(maxLifeTime int64)
- func (frommemory *FromMemory) SessionInit(sid string) (Session, error)
- func (frommemory *FromMemory) SessionRead(sid string) (Session, error)
- func (frommemory *FromMemory) SessionUpdate(sid string) error
- type Manage
- type Provider
- type Session
- type SessionStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FromMemory ¶
type FromMemory struct {
// contains filtered or unexported fields
}
session来自内存 实现
func (*FromMemory) SessionDestroy ¶
func (frommemory *FromMemory) SessionDestroy(sid string) error
func (*FromMemory) SessionGC ¶
func (frommemory *FromMemory) SessionGC(maxLifeTime int64)
func (*FromMemory) SessionInit ¶
func (frommemory *FromMemory) SessionInit(sid string) (Session, error)
func (*FromMemory) SessionRead ¶
func (frommemory *FromMemory) SessionRead(sid string) (Session, error)
func (*FromMemory) SessionUpdate ¶
func (frommemory *FromMemory) SessionUpdate(sid string) error
type Manage ¶
type Manage struct {
// contains filtered or unexported fields
}
session管理
func NewManager ¶
实例化一个session管理器
func (*Manage) SessionDestroy ¶
func (manager *Manage) SessionDestroy(w http.ResponseWriter, r *http.Request)
销毁session 同时删除cookie
func (*Manage) SessionStart ¶
判断当前请求的cookie中是否存在有效的session,存在返回,否则创建
type Provider ¶
type Provider interface { //初始化一个session,sid根据需要生成后传入 SessionInit(sid string) (Session, error) //根据sid,获取session SessionRead(sid string) (Session, error) //销毁session SessionDestroy(sid string) error //回收 SessionGC(maxLifeTime int64) }
session存储方式接口
type Session ¶
type Session interface { Get(key interface{}) interface{} Set(key, value interface{}) error Delete(key interface{}) error SessionID() string }
Session操作接口
type SessionStore ¶
type SessionStore struct { LastAccessedTime time.Time //最后访问时间 // contains filtered or unexported fields }
session实现
func (*SessionStore) SessionID ¶
func (st *SessionStore) SessionID() string
Click to show internal directories.
Click to hide internal directories.