ssdbsession

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MIN_SESS_LEN int = 48

////////////////////////////////////////////////////////////////////////

View Source
const SECRETKEY string = "AILTFG784084FPGVB"

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionMgr

type SessionMgr struct {
	CookieName      string
	CookieLifeTime  int
	SessionLifetime int
	Secure          bool
	Domain          string
	Pool            *redis.Pool
	// contains filtered or unexported fields
}

func New

func New(RedisAddr string, Pass string, CookieName string, CookieLifeSeconds int, SessionLifeSeconds int, Secure bool, szdomain string) (*SessionMgr, error)

func (*SessionMgr) DelAllSessionByUserID

func (s *SessionMgr) DelAllSessionByUserID(userid string) error

func (*SessionMgr) DelCookie

func (s *SessionMgr) DelCookie(w http.ResponseWriter, r *http.Request)

清除浏览器cookie

func (*SessionMgr) DelSession

func (s *SessionMgr) DelSession(session string) error

退出登录后删除session

func (*SessionMgr) DelSessionValue

func (s *SessionMgr) DelSessionValue(session string, keys ...interface{}) error

func (*SessionMgr) GetAllSessionByUserID

func (s *SessionMgr) GetAllSessionByUserID(userid string) ([]string, error)

func (*SessionMgr) GetCookie

func (s *SessionMgr) GetCookie(r *http.Request) string

从cookie中提取session

func (*SessionMgr) GetSessionAllKeys

func (s *SessionMgr) GetSessionAllKeys(session string) ([]string, error)

func (*SessionMgr) GetSessionBool

func (s *SessionMgr) GetSessionBool(session string, key string) (bool, error)

func (*SessionMgr) GetSessionBytes

func (s *SessionMgr) GetSessionBytes(session string, key string) ([]byte, error)

func (*SessionMgr) GetSessionFloat64

func (s *SessionMgr) GetSessionFloat64(session string, key string) (float64, error)

func (*SessionMgr) GetSessionInt64

func (s *SessionMgr) GetSessionInt64(session string, key string) (int64, error)

func (*SessionMgr) GetSessionString

func (s *SessionMgr) GetSessionString(session string, key string) (string, error)

func (*SessionMgr) IsSessionValid

func (s *SessionMgr) IsSessionValid(session string) (bool, error)

校验session是否有效

func (*SessionMgr) NewSession

func (s *SessionMgr) NewSession(userid string) (string, error)

登录后创建新cookie,存入缓存 48 bytes + userid

func (*SessionMgr) SessionKeepAlive

func (s *SessionMgr) SessionKeepAlive(session string, lastAccessTime int64)

每次访问后调用该函数,重新设置session生命期

func (*SessionMgr) SetCookie

func (s *SessionMgr) SetCookie(w http.ResponseWriter, r *http.Request, szCookie string) error

func (*SessionMgr) SetSessionValue

func (s *SessionMgr) SetSessionValue(session string, kvs ...interface{}) error

Jump to

Keyboard shortcuts

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