ofxHTTP
A collection of tools for HTTP.
ofx::HTTP::BaseSessionStore Class Referenceabstract
Inheritance diagram for ofx::HTTP::BaseSessionStore:
ofx::HTTP::AbstractSessionStore ofx::HTTP::SimpleSessionStore

Public Member Functions

 BaseSessionStore (const std::string &sessionKeyName)
 
AbstractSessiongetSession (Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response)
 Get a valid session for the given request. More...
 
void destroySession (Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response)
 Destroy the session(s) associated with the given exchange. More...
 
- Public Member Functions inherited from ofx::HTTP::AbstractSessionStore
virtual ~AbstractSessionStore ()
 Destroy the AbstractSessionStore.
 

Static Public Attributes

static const std::string DEFAULT_SESSION_KEY_NAME = "session_key"
 

Protected Member Functions

virtual bool hasSession (const std::string &sessionId) const =0
 Query if the store has the the given session. More...
 
virtual AbstractSessiongetSession (const std::string &sessionId)=0
 Get a session by sesssionId. More...
 
virtual AbstractSessioncreateSession ()=0
 Create a completely new session. More...
 
virtual void destroySession (const std::string &sessionId)=0
 Destroy the record of a session by its session id. More...
 

Protected Attributes

const std::string _sessionKeyName
 

Member Function Documentation

◆ createSession()

virtual AbstractSession& ofx::HTTP::BaseSessionStore::createSession ( )
protectedpure virtual

Create a completely new session.

Since this returns a reference, the newly created session must be stored outside of the local method scope so the reference does not become invalid.

Returns
A reference to the newly created session.

Implements ofx::HTTP::AbstractSessionStore.

Implemented in ofx::HTTP::SimpleSessionStore.

◆ destroySession() [1/2]

void ofx::HTTP::BaseSessionStore::destroySession ( Poco::Net::HTTPServerRequest &  request,
Poco::Net::HTTPServerResponse &  response 
)
virtual

Destroy the session(s) associated with the given exchange.

This method will invalidate any session cookies in the response header. If session data does not exist, the method will return quietly.

Implements ofx::HTTP::AbstractSessionStore.

◆ destroySession() [2/2]

virtual void ofx::HTTP::BaseSessionStore::destroySession ( const std::string &  sessionId)
protectedpure virtual

Destroy the record of a session by its session id.

If session data does not exist, the method will return quietly.

Parameters
sessionIdThe id of the session to destroy.

Implements ofx::HTTP::AbstractSessionStore.

Implemented in ofx::HTTP::SimpleSessionStore.

◆ getSession() [1/2]

AbstractSession & ofx::HTTP::BaseSessionStore::getSession ( Poco::Net::HTTPServerRequest &  request,
Poco::Net::HTTPServerResponse &  response 
)
virtual

Get a valid session for the given request.

This method is guaranteed to provide a valid session the session created will expire when teh browser window is closed. Other method will be able to update the cookie in the response headers if more speific cookie parameters are desired.

This method will also ensure that only one session id is availble at a given time

Parameters
requestThe HTTP request.
responseThe HTTP response.
Returns
A reference to an AbstractSession.

Implements ofx::HTTP::AbstractSessionStore.

◆ getSession() [2/2]

virtual AbstractSession& ofx::HTTP::BaseSessionStore::getSession ( const std::string &  sessionId)
protectedpure virtual

Get a session by sesssionId.

Parameters
sessionIdThe id of the session to get.
Exceptions
Poco::InvalidAccessExceptionif no session is found.

Implements ofx::HTTP::AbstractSessionStore.

Implemented in ofx::HTTP::SimpleSessionStore.

◆ hasSession()

virtual bool ofx::HTTP::BaseSessionStore::hasSession ( const std::string &  sessionId) const
protectedpure virtual

Query if the store has the the given session.

Parameters
sessionIdThe id of the session to query.

Implements ofx::HTTP::AbstractSessionStore.

Implemented in ofx::HTTP::SimpleSessionStore.


The documentation for this class was generated from the following files: