Documentation
¶
Overview ¶
Package session provides typed, nil-safe accessors for the values the framework stores on a github.com/gorilla/sessions.Session, plus a helper to obtain the session's github.com/mikehelmick/go-bananas/flash.Flash.
Storing values through these helpers keeps key names and value types consistent between the middleware that writes them and the handlers that read them. Every accessor tolerates a nil session.
Index ¶
- func CSRFToken(session *sessions.Session) []byte
- func ClearCSRFToken(session *sessions.Session)
- func ClearLastActivity(session *sessions.Session)
- func ClearNonce(session *sessions.Session)
- func ClearRegion(session *sessions.Session)
- func Flash(session *sessions.Session) *flash.Flash
- func LastActivity(session *sessions.Session) time.Time
- func Nonce(session *sessions.Session) string
- func Region(session *sessions.Session) string
- func StoreCSRFToken(session *sessions.Session, token []byte)
- func StoreLastActivity(session *sessions.Session, t time.Time)
- func StoreNonce(session *sessions.Session, nonce string)
- func StoreRegion(session *sessions.Session, region string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CSRFToken ¶
CSRFToken returns the CSRF token stored on the session, or nil if absent or malformed (in which case it is also cleared).
func ClearCSRFToken ¶
ClearCSRFToken removes the CSRF token from the session.
func ClearLastActivity ¶
ClearLastActivity removes the last-activity time from the session.
func ClearNonce ¶
ClearNonce removes the nonce from the session.
func ClearRegion ¶
ClearRegion removes the region from the session.
func Flash ¶
Flash returns the flash.Flash for the provided session, initializing the session's value map if necessary. It tolerates a nil session.
func LastActivity ¶
LastActivity returns the time of the user's last activity, or the zero time if absent or malformed (in which case it is also cleared).
func StoreCSRFToken ¶
StoreCSRFToken stores the CSRF token on the session. A nil session or zero-length token is a no-op.
func StoreLastActivity ¶
StoreLastActivity stores the time of the user's last activity, used to track idle session timeouts. A nil session is a no-op.
func StoreNonce ¶
StoreNonce stores the session's current nonce value. A nil session is a no-op.
func StoreRegion ¶
StoreRegion stores the current operating region in the session. A nil session is a no-op.
Types ¶
This section is empty.