Documentation ¶
Index ¶
- Constants
- Variables
- func InitSession(coreLogger logger.MultiLogger)
- type Session
- func (s Session) Del(key string)
- func (s Session) Empty() bool
- func (s Session) Get(key string) (newValue interface{}, err error)
- func (s Session) GetDefault(key string, value interface{}, defaultValue interface{}) interface{}
- func (s Session) GetExpiration(expireAfterDuration time.Duration) time.Time
- func (s Session) GetInto(key string, target interface{}, force bool) (result interface{}, err error)
- func (s Session) GetProperty(key string, value interface{}) (interface{}, error)
- func (s Session) ID() string
- func (s Session) Load(data map[string]string)
- func (s Session) Serialize() map[string]string
- func (s Session) SessionTimeoutExpiredOrMissing() bool
- func (s Session) Set(key string, value interface{}) error
- func (s Session) SetDefaultExpiration()
- func (s Session) SetNoExpiration()
Constants ¶
const ( // The key for the identity of the session. SessionIDKey = "_ID" // The expiration date of the session. TimestampKey = "_TS" // The value name indicating how long the session should persist - ie should it persist after the browser closes // this is set under the TimestampKey if the session data should expire immediately. SessionValueName = "session" // The key container for the json objects of the data, any non strings found in the map will be placed in here // serialized by key using JSON. SessionObjectKeyName = "_object_" // The mapped session object. SessionMapKeyName = "_map_" // The suffix of the session cookie. SessionCookieSuffix = "_SESSION" )
Variables ¶
var SESSION_VALUE_NOT_FOUND = errors.New("Session value not found")
Constant error if session value is not found.
Functions ¶
func InitSession ¶
func InitSession(coreLogger logger.MultiLogger)
Types ¶
type Session ¶
type Session map[string]interface{}
Session data, can be any data, there are reserved keywords used by the storage data SessionIDKey Is the key name for the session TimestampKey Is the time that the session should expire
func NewSession ¶
func NewSession() Session
func (Session) Get ¶
Get an object or property from the session it may be embedded inside the session.
func (Session) GetDefault ¶
Returns the default value if the key is not found.
func (Session) GetExpiration ¶
getExpiration return a time.Time with the session's expiration date. It uses the passed in expireAfterDuration to add with the current time if the timeout is not browser dependent (ie session). If previous session has set to "session", the time returned is time.IsZero().
func (Session) GetInto ¶
func (s Session) GetInto(key string, target interface{}, force bool) (result interface{}, err error)
Get into the specified value. If value exists in the session it will just return the value.
func (Session) GetProperty ¶
Extract the values from the session.
func (Session) ID ¶
ID retrieves from the cookie or creates a time-based UUID identifying this session.
func (Session) Serialize ¶
Convert the map to a simple map[string]string map this will marshal any non string objects encountered and store them the the jsonMap The expiration time will also be assigned.
func (Session) SessionTimeoutExpiredOrMissing ¶
sessionTimeoutExpiredOrMissing returns a boolean of whether the session cookie is either not present or present but beyond its time to live; i.e., whether there is not a valid session.
func (Session) Set ¶
Places the object into the session, a nil value will cause remove the key from the session (or you can use the Session.Del(key) function.
func (Session) SetDefaultExpiration ¶
func (s Session) SetDefaultExpiration()
SetDefaultExpiration sets session to expire after default duration.
func (Session) SetNoExpiration ¶
func (s Session) SetNoExpiration()
SetNoExpiration sets session to expire when browser session ends.