session

package
v0.0.0-...-0193369 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, provider Provider)

Register makes a session provider available by the provided name. If a Register is called twice with the same name or if the driver is nil, it panics.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}
var GlobalSessions *Manager

func NewManager

func NewManager(provideName, cookieName string, maxlifetime int64) (*Manager, error)

func (*Manager) GC

func (manager *Manager) GC()

func (*Manager) SessionDestroy

func (manager *Manager) SessionDestroy(w http.ResponseWriter, r *http.Request)

func (*Manager) SessionStart

func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (session Session)

type Provider

type Provider interface {
	SessionInit(sid string) (Session, error)
	SessionRead(sid string) (Session, error)
	SessionDestroy(sid string) error
	SessionGC(maxLifeTime int64)
}

type Session

type Session interface {
	Set(key, value interface{}) error //set session value
	Get(key interface{}) interface{}  //get session value
	Delete(key interface{}) error     //delete session value
	SessionID() string                //back current sessionID
}

Jump to

Keyboard shortcuts

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