Raxx.Session - manage client sessions, plug compatible

web-frameworks
raxx
web
#1

Example

@session_config Raxx.Session.config(
                    key: "my_session",
                    store: Raxx.Session.SignedCookie,
                    secret_key_base: String.duplicate("squirrel", 8),
                    salt: "epsom"
                  )
# Or configure at runtime and pass as state argument to server.

def handle_request(request, _state) do
  {:ok, session} = Raxx.Session.fetch(request, @session_config)

  # ... processing
  response(:ok)
  |> Raxx.Session.put(updated_session, @session_config)

  # ... something went wrong
  response(:forbiddent)
  |> Raxx.Session.drop(@session_config)
end

Plug compatibility.

By using the SignedCookie store your sessions are compatible with verified plug sessions.

I am looking for help to port the encrypted plug sessions to this library and create a second store for EncryptedCookie hopefully I will be able to announce that below soon’

3 Likes
#2

Raxx.Session.EncryptedCookie

Release 0.2.3 adds support for adding encrypted sessions in addition to signed sessions.

Example configuration:

  Raxx.Session.config(
    store: Raxx.Session.EncryptedCookie,
    secret_key_base: secret_key_base,
    key: key,
    encryption_salt: encryption_salt,
    signing_salt: signing_salt
  )

These sessions are also compatible with Plug.Sessions set up with the same secret_key_base encryption_salt and signing_salt

1 Like