Documentation ¶
Index ¶
- type Message
- type MessageType
- type Session
- type SessionManager
- func (m *SessionManager) AddMessage(w http.ResponseWriter, t MessageType, msg string)
- func (m *SessionManager) CreateSession(lt time.Time) (*Session, error)
- func (m *SessionManager) GetCookieValue(r *http.Request) (string, error)
- func (m *SessionManager) GetMessage(w http.ResponseWriter, r *http.Request) (MessageType, string, error)
- func (m *SessionManager) GetSession(id string) (*Session, error)
- func (m *SessionManager) GetSessionFromCookie(r *http.Request) (*Session, error)
- func (m *SessionManager) GetSessionFromUrl(u *url.URL) (*Session, error)
- func (m *SessionManager) RemoveAllSessions()
- func (m *SessionManager) RemoveCookie(w http.ResponseWriter, name string)
- func (m *SessionManager) RemoveSession(id string) error
- func (m *SessionManager) SetCookie(w http.ResponseWriter, value string, expires time.Time)
- func (m *SessionManager) ToFile(file string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct { MessageType MessageType Content string }
type MessageType ¶ added in v2.2.0
type MessageType string
const ( MessageSuccess MessageType = "success" MessageError MessageType = "error" MessageWarning MessageType = "warning" MessageInfo MessageType = "info" )
type Session ¶
type Session struct { Id string Lifetime time.Time Vars map[string]string Message Message // contains filtered or unexported fields }
func (*Session) GetMessage ¶
GetMessage returns a previously set message
func (*Session) GetVar ¶
GetVar returns whether the variable with the given name and the actual value, if it exists
func (*Session) SetMessage ¶
func (s *Session) SetMessage(t MessageType, content string)
SetMessage sets a flash message to the *Session
Deprecated
type SessionManager ¶
type SessionManager struct { SessionName string Sessions []*Session // contains filtered or unexported fields }
func NewManager ¶
func NewManager(sn string) *SessionManager
NewManager creates and returns a new *SessionManager
func NewManagerFromFile ¶
func NewManagerFromFile(file string) (*SessionManager, error)
func (*SessionManager) AddMessage ¶ added in v2.1.0
func (m *SessionManager) AddMessage(w http.ResponseWriter, t MessageType, msg string)
func (*SessionManager) CreateSession ¶
func (m *SessionManager) CreateSession(lt time.Time) (*Session, error)
CreateSession creates a new Session under the *SessionManager
func (*SessionManager) GetCookieValue ¶
func (m *SessionManager) GetCookieValue(r *http.Request) (string, error)
GetCookieValue fetches the session ID from the session cookie of a given request
func (*SessionManager) GetMessage ¶ added in v2.1.0
func (m *SessionManager) GetMessage(w http.ResponseWriter, r *http.Request) (MessageType, string, error)
func (*SessionManager) GetSession ¶
func (m *SessionManager) GetSession(id string) (*Session, error)
GetSession retrieves the Session with the supplied session ID
func (*SessionManager) GetSessionFromCookie ¶
func (m *SessionManager) GetSessionFromCookie(r *http.Request) (*Session, error)
GetSessionFromCookie is a convenience method to find an existing session by taking the session ID from the cookie with the name initially set when creating the *SessionManager.
func (*SessionManager) GetSessionFromUrl ¶
func (m *SessionManager) GetSessionFromUrl(u *url.URL) (*Session, error)
GetSessionFromUrl is a convenience method to find an existing session by taking the session ID from a *url.URL query parameter.
func (*SessionManager) RemoveAllSessions ¶
func (m *SessionManager) RemoveAllSessions()
RemoveAllSessions removes all Sessions from a *SessionManager
func (*SessionManager) RemoveCookie ¶
func (m *SessionManager) RemoveCookie(w http.ResponseWriter, name string)
RemoveCookie is a convenience method to remove the session cookie (s
func (*SessionManager) RemoveSession ¶
func (m *SessionManager) RemoveSession(id string) error
RemoveSession removes the Session with the supplied session ID
func (*SessionManager) SetCookie ¶
func (m *SessionManager) SetCookie(w http.ResponseWriter, value string, expires time.Time)
SetCookie is a convenience method to set a session cookie with the initially chosen name.
func (*SessionManager) ToFile ¶
func (m *SessionManager) ToFile(file string) error