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" )
Constant error if session value is not found
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
Delete the key from the sessionObjects and Session
Checks to see if the session is empty
Get an object or property from the session it may be embedded inside the session.
Returns the default value if the key is not found
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()
Get into the specified value. If value exists in the session it will just return the value
Extract the values from the session
ID retrieves from the cookie or creates a time-based UUID identifying this session.
Set the session object from the loaded data
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
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.
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
SetDefaultExpiration sets session to expire after default duration
SetNoExpiration sets session to expire when browser session ends