-
mutable struct Session

Represents a session object

source
Genie.Sessions.idFunction.
id() :: String

Generates a new session id.

source
id(payload::Union{HTTP.Request,HTTP.Response}) :: String

Attempts to retrieve the session id from the provided payload object. If that is not available, a new session id is created.

source
id(req::HTTP.Request, res::HTTP.Response) :: String

Attempts to retrieve the session id from the provided request and response objects. If that is not available, a new session id is created.

source
Genie.Sessions.startFunction.
start(session_id::String, req::HTTP.Request, res::HTTP.Response; options = Dict{String,String}()) :: Session

Initiates a new HTTP session with the provided session_id.

Arguments

  • session_id::String: the id of the session object
  • req::HTTP.Request: the request object
  • res::HTTP.Response: the response object
  • options::Dict{String,String}: extra options for setting the session cookie, such as Path and HttpOnly
source
start(req::HTTP.Request, res::HTTP.Response; options::Dict{String,String} = Dict{String,String}()) :: Session

Initiates a new default session object, generating a new session id.

Arguments

  • req::HTTP.Request: the request object
  • res::HTTP.Response: the response object
  • options::Dict{String,String}: extra options for setting the session cookie, such as Path and HttpOnly
source
Genie.Sessions.set!Function.
set!(s::Session, key::Symbol, value::Any) :: Session

Stores value as key on the Session object s.

source
Genie.Sessions.getFunction.
get(s::Session, key::Symbol) :: Nullable

Returns the value stored on the Session object s as key, wrapped in a Nullable.

source
get(s::Session, key::Symbol, default::T) :: T where T

Attempts to retrive the value stored on the Session object s as key. If the value is not set, it returns the default.

source
Genie.Sessions.get!!Function.
get!!(s::Session, key::Symbol)

Attempts to read the value stored on the Session s as key - throws an exception if the key is not set.

source
Genie.Sessions.unset!Function.
unset!(s::Session, key::Symbol) :: Session

Removes the value stored on the Session s as key.

source
Genie.Sessions.issetFunction.
isset(s::Session, key::Symbol) :: Bool

Checks wheter or not key exists on the Session s.

source
session(params::Dict{Symbol,Any}) :: Sessions.Session

Returns the Session object associated with the current HTTP request.

source