session

package
v0.0.0-...-d30b894 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterType

func RegisterType(value interface{})

func RegisterTypeName

func RegisterTypeName(name string, value interface{})

func UseAsDefault

func UseAsDefault(manager *Manager)

UseAsDefault use the given session manager as the default

Types

type Config

type Config struct {
	CookieName      string `xml:"cookieName,attr"`
	CookiePath      string `xml:"cookiePath,attr"`
	EnableSetCookie bool   `xml:"enableSetCookie,attr"`
	GcLifetime      int64  `xml:"gcLifetime,attr"`
	MaxLifetime     int64  `xml:"maxLifetime,attr"`
	Secure          bool   `xml:"secure,attr"`
	HTTPOnly        bool   `xml:"httpOnly,attr"`
	CookieLifeTime  int    `xml:"cookieLifeTime,attr"`
	ProviderConfig  string `xml:"providerConfig,attr"`
	Domain          string `xml:"domain,attr"`
}

type Manager

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

Manager the session manager struct

func CreateManager

func CreateManager(config *Config, provider Provider) *Manager

func Default

func Default() *Manager

func (*Manager) Destroy

func (manager *Manager) Destroy(ctx *mego.HttpCtx)

Destroy Destroy session by its id in http request cookie.

func (*Manager) RegenerateID

func (manager *Manager) RegenerateID(ctx *mego.HttpCtx) (session Storage)

RegenerateID Regenerate a session id for this Storage who's id is saving in http request.

func (*Manager) Start

func (manager *Manager) Start(ctx *mego.HttpCtx) Storage

Start generate or read the session id from http request. if session id exists, return Storage with this id.

type Provider

type Provider interface {
	Init(gcLifetime int64, config string) error
	Read(sid string) Storage
	Exist(sid string) bool
	Regenerate(oldSid, sid string) (Storage, error)
	Destroy(sid string) error
	All() int //get all active session
	Update(sid string) error
	GC()
}

Provider contains global session methods and saved SessionStores. it can operate a Storage by its id.

type Storage

type Storage interface {
	Set(key string, value interface{}) error //set session Value
	Get(key string) interface{}              //get session Value
	Delete(key string) error                 //delete session Value
	ID() string                              //back current sessionID
	Release(w http.ResponseWriter)           //release the resource & save data to provider & return the data
	Flush() error                            //delete all data
}

Storage the session store interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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