session

package
v0.1.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2024 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	// contains filtered or unexported fields
}

func (*Session) Delete

func (this *Session) Delete(key interface{}) error

func (*Session) Get

func (this *Session) Get(key interface{}) interface{}

func (*Session) IsNew

func (this *Session) IsNew() bool

func (*Session) SessionID

func (this *Session) SessionID() string

func (*Session) Set

func (this *Session) Set(key, value interface{}) error

* Set(key, value interface{}) error //设置Session Get(key interface{}) interface{} //获取Session Delete(key interface{}) error //删除Session SessionID() string //当前SessionID

type SessionManager

type SessionManager struct {
	// contains filtered or unexported fields
}

* 会话管理器获取当前会话,GetDefault().Start(),从而进一步获取会话id,会话变量的存取

func GetDefault

func GetDefault() *SessionManager

func NewSessionManager

func NewSessionManager(poolName, cookieName string, maxLifetime int64) (*SessionManager, error)

func (*SessionManager) SessionDestroy

func (this *SessionManager) SessionDestroy(w http.ResponseWriter, r *http.Request)

SessionDestroy 注销 Session

func (*SessionManager) SessionGC

func (this *SessionManager) SessionGC()

func (*SessionManager) Start

func (this *SessionManager) Start(w http.ResponseWriter, r *http.Request) (session *Session)

根据当前请求的cookie中判断是否存在有效的session, 不存在则创建

type SessionPool

type SessionPool struct {
	// contains filtered or unexported fields
}

* 会话池用于存放连接上来的多个会话,会话管理器Start的时候如果是新会话,将放入会话池

func (*SessionPool) Destroy

func (this *SessionPool) Destroy(sid string) error

func (*SessionPool) Init

func (this *SessionPool) Init(sid string) (*Session, error)

* SessionInit(sid string) (Session, error) SessionRead(sid string) (Session, error) SessionDestroy(sid string) error SessionGC(maxLifeTime int64)

func (*SessionPool) Read

func (this *SessionPool) Read(sid string) (*Session, error)

func (*SessionPool) SessionGC

func (this *SessionPool) SessionGC(maxlifetime int64)

func (*SessionPool) Update

func (this *SessionPool) Update(sid string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL