revel: Index | Files

package session

import ""


Package Files

init.go session.go


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"


var SESSION_VALUE_NOT_FOUND = errors.New("Session value not found")

Constant error if session value is not found

func InitSession Uses

func InitSession(coreLogger logger.MultiLogger)

type Session Uses

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 Uses

func NewSession() Session

func (Session) Del Uses

func (s Session) Del(key string)

Delete the key from the sessionObjects and Session

func (Session) Empty Uses

func (s Session) Empty() bool

Checks to see if the session is empty

func (Session) Get Uses

func (s Session) Get(key string) (newValue interface{}, err error)

Get an object or property from the session it may be embedded inside the session.

func (Session) GetDefault Uses

func (s Session) GetDefault(key string, value interface{}, defaultValue interface{}) interface{}

Returns the default value if the key is not found

func (Session) GetExpiration Uses

func (s Session) GetExpiration(expireAfterDuration time.Duration) time.Time

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 Uses

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 Uses

func (s Session) GetProperty(key string, value interface{}) (interface{}, error)

Extract the values from the session

func (Session) ID Uses

func (s Session) ID() string

ID retrieves from the cookie or creates a time-based UUID identifying this session.

func (Session) Load Uses

func (s Session) Load(data map[string]string)

Set the session object from the loaded data

func (Session) Serialize Uses

func (s Session) Serialize() map[string]string

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 Uses

func (s Session) SessionTimeoutExpiredOrMissing() bool

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 Uses

func (s Session) Set(key string, value interface{}) error

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 Uses

func (s Session) SetDefaultExpiration()

SetDefaultExpiration sets session to expire after default duration

func (Session) SetNoExpiration Uses

func (s Session) SetNoExpiration()

SetNoExpiration sets session to expire when browser session ends

Package session imports 9 packages (graph) and is imported by 11 packages. Updated 2020-07-12. Refresh now. Tools for package owners.