Skip to content

abstract class Athena::HTTP::Session::Storage::Handler::AbstractHandler
inherits Reference #

Base type of the built-in session handlers.

Makes sure a session is never brought back after it was destroyed: the data of a session that did not exist when it was read is only ever created via #do_create, and the data of an existing session only ever updated via #do_write. E.g. a request still using a session that another request destroyed, such as when logging out, does not bring it back.

Also removes the session when it is written with empty data, and skips removing a session that was never persisted.

As it keeps track of the session it last read, an instance must not be shared between concurrent requests, e.g. by storing it in a class variable.

Included modules

Athena::HTTP::Session::Storage::Handler::Interface

Direct known subclasses

Athena::HTTP::Session::Storage::Handler::File Athena::HTTP::Session::Storage::Handler::Memory Athena::HTTP::Session::Storage::Handler::Null

Methods#

#close : Nil#

Releases any resources held for the current session.

View source

#destroy(session_id : String) : Bool#

Removes the session with the provided session_id. Returns true if it no longer exists, otherwise false.

View source

#read(session_id : String) : String#

Returns the data of the session with the provided session_id, or an empty string if it does not exist or has expired.

View source

#update_timestamp(session_id : String, data : String) : Bool#

Updates when the session with the provided session_id was last used, without changing its data. Returns true if it was updated, otherwise false.

View source

#write(session_id : String, data : String) : Bool#

Persists the provided data as that of the session with the provided session_id. Returns true if it was persisted, otherwise false.

View source