session

package
v0.0.0-...-213cbcb Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2020 License: MIT 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 creates a session provider with the provided name

Types

type Manager

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

Manager is the interface for session manager

func NewManager

func NewManager(providerName, cookieName string, maxlifetime int) (*Manager, error)

NewManager creates a new session manager and returns its pointer reference

func (*Manager) GC

func (manager *Manager) GC()

GC deletes sessions after their allowed lifetime

func (*Manager) GetCookie

func (manager *Manager) GetCookie(r *http.Request) (*http.Cookie, error)

GetCookie returns the cookie set associated with the request

func (*Manager) SessionCheck

func (manager *Manager) SessionCheck(r *http.Request) (Session, bool)

SessionCheck checks if any session associated with the request exists and returns the session if found

func (*Manager) SessionDestroy

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

SessionDestroy deletes any existing session associated with the request

func (*Manager) SessionStart

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

SessionStart checks if any session associated with the request exists and creates assigns a new one if not present

type Provider

type Provider interface {
	SessionInit(sid string) Session
	SessionRead(sid string) Session
	SessionDestroy(sid string)
	SessionGC(maxlifetime int)
}

Provider is the interface for providers

type Session

type Session interface {
	Set(key, value interface{})
	Get(key interface{}) interface{}
	Delete(key interface{})
	SessionId() string
}

Session is the interface for all the sessions

Directories

Path Synopsis
providers

Jump to

Keyboard shortcuts

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