Documentation ¶
Index ¶
- Constants
- type SessionMgr
- func (s *SessionMgr) DelAllSessionByUserID(userid string) error
- func (s *SessionMgr) DelCookie(w http.ResponseWriter, r *http.Request)
- func (s *SessionMgr) DelSession(session string) error
- func (s *SessionMgr) DelSessionValue(session string, keys ...interface{}) error
- func (s *SessionMgr) GetAllSessionByUserID(userid string) ([]string, error)
- func (s *SessionMgr) GetCookie(r *http.Request) string
- func (s *SessionMgr) GetSessionAllKeys(session string) ([]string, error)
- func (s *SessionMgr) GetSessionBool(session string, key string) (bool, error)
- func (s *SessionMgr) GetSessionBytes(session string, key string) ([]byte, error)
- func (s *SessionMgr) GetSessionFloat64(session string, key string) (float64, error)
- func (s *SessionMgr) GetSessionInt64(session string, key string) (int64, error)
- func (s *SessionMgr) GetSessionString(session string, key string) (string, error)
- func (s *SessionMgr) IsSessionValid(session string) (bool, error)
- func (s *SessionMgr) NewSession(userid string) (string, error)
- func (s *SessionMgr) SessionKeepAlive(session string, lastAccessTime int64)
- func (s *SessionMgr) SetCookie(w http.ResponseWriter, r *http.Request, szCookie string) error
- func (s *SessionMgr) SetSessionValue(session string, kvs ...interface{}) error
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 (*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
Click to show internal directories.
Click to hide internal directories.