Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptySessionId error = errors.New("session: sid cannot be empty") ErrDuplicatedSessionId error = errors.New("session: cannot duplicate sid") ErrUnableToRestoreSession error = errors.New("session: unable to restore session (storage failure)") ErrUnableToEnsureNonDuplicity error = errors.New("session: unable to ensure non-duplicity of sid (storage failure)") ErrUnableToDestroySession error = errors.New("session: unable to destroy session (storage failure)") ErrUnableToSaveSession error = errors.New("session: unable to save session (storage failure)") )
Functions ¶
func NewProvider ¶
func NewProvider(storage Storage, adapter AgeCheckerAdapter) *defaultProvider
Returns a new defaultProvider (address for pointer reference).
Types ¶
type AgeChecker ¶
type AgeCheckerAdapter ¶
type AgeCheckerAdapter func(int64) AgeChecker
var SecondsAgeCheckerAdapter AgeCheckerAdapter = func(maxAge int64) AgeChecker {
return secondsAgeChecker(maxAge)
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager allows to work with sessions.
It can start or destroy one session. Both operations will manipulate a http cookie.
To start a session, it will: - Creates a new one, setting a http cookie; or - Retrieves, accordingly to the existent http cookie.
To destroys a session, it can be forced or after it expires. The expired session is removed through the GC routine, which checks this condition.
func NewManager ¶
Returns a new Manager (address for pointer reference).
The provider cannot be nil and cookie name cannot be empty.
func (*Manager) DestroySession ¶
func (m *Manager) DestroySession(w http.ResponseWriter, r *http.Request)
Destroys the session, finally cleaning up the http cookie.
func (*Manager) GC ¶
func (m *Manager) GC()
Creates a routine to check for expired sessions and remove them.
func (*Manager) StartSession ¶
Creates or retrieve the session based on the http cookie.