gosession

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

gosession

Easy to use go session component

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Register

func Register(name string, store StoreInterface)

注册存储器

Types

type IdFunc

type IdFunc = func() string

type Manager

type Manager struct {
	CookieName string
	// contains filtered or unexported fields
}

func NewDefaultIDManager

func NewDefaultIDManager(storeName string, cookieName string, maxlifetime int) (*Manager, error)

func NewManager

func NewManager(storeName string, cookieName string, maxlifetime int, f IdFunc) (*Manager, error)

func (*Manager) GetSession

func (manager *Manager) GetSession(w http.ResponseWriter, r *http.Request) (s *Session)

获取session

func (*Manager) NewSesssion

func (manager *Manager) NewSesssion(sid string) *Session

生成session结构体

type Session

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

func (*Session) Delete

func (s *Session) Delete(key string) error

func (*Session) DestroySession

func (s *Session) DestroySession(w http.ResponseWriter, r *http.Request)

func (*Session) Get

func (s *Session) Get(key string) (interface{}, error)

func (*Session) Set

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

type StoreInterface

type StoreInterface interface {
	//删除某个key的值
	Remove(Sid string, key string) error
	//获取某个key的值
	Get(Sid string, key string) (interface{}, error)
	//设置某个key的值
	Set(Sid string, key string, value interface{}, ttl int) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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