ofxHTTP
A collection of tools for HTTP.
ofx::HTTP::SimpleSession Class Reference

A client cookie-based session store for servers. More...

#include <Session.h>

Inheritance diagram for ofx::HTTP::SimpleSession:
ofx::HTTP::BaseSession ofx::HTTP::AbstractSession

Public Member Functions

 SimpleSession (const std::string &sessionId=generateId())
 
bool has (const std::string &key) const override
 Check to see if the provided key exists in the session data. More...
 
void put (const std::string &key, const std::string &value) override
 Add (or replace) a key in the sesion data with the given value. More...
 
std::string get (const std::string &key, const std::string &defaultValue) const override
 Get the session data for a given key, or a default value. More...
 
std::string get (const std::string &key) const override
 Get the session data for a given key, or throw an exception. More...
 
void remove (const std::string &key) override
 Remove a key / value pair. More...
 
void clear () override
 Remove all data from the session.
 
- Public Member Functions inherited from ofx::HTTP::BaseSession
 BaseSession (const std::string sessionId=generateId())
 
std::string getId () const override
 Get the session id. More...
 
- Public Member Functions inherited from ofx::HTTP::AbstractSession
virtual ~AbstractSession ()
 Destroy the AbstractSession.
 

Protected Member Functions

 SimpleSession (const SimpleSession &)
 
SimpleSessionoperator= (const SimpleSession &)
 
- Protected Member Functions inherited from ofx::HTTP::BaseSession
 BaseSession (const BaseSession &)
 
BaseSessionoperator= (const BaseSession &)
 

Protected Attributes

std::map< std::string, std::string > _sessionDict
 
- Protected Attributes inherited from ofx::HTTP::BaseSession
std::string _sessionId
 
std::mutex _mutex
 

Additional Inherited Members

- Static Public Member Functions inherited from ofx::HTTP::BaseSession
static std::string generateId ()
 A utility function for generating unique session ids. More...
 
- Static Public Attributes inherited from ofx::HTTP::BaseSession
static const std::string KEY_LAST_MODIFIED = "last_modified"
 

Detailed Description

A client cookie-based session store for servers.

Client sessions are tracked via cookie. Server routes can access the session store and associate any information with the client's session.

Member Function Documentation

◆ get() [1/2]

std::string ofx::HTTP::SimpleSession::get ( const std::string &  key,
const std::string &  defaultValue 
) const
overridevirtual

Get the session data for a given key, or a default value.

Parameters
keyThe data key to get.
defaultValueThe data value to return if the key does not exist.
Returns
the data value for the key or the defaultValue if the key does not exist.

Implements ofx::HTTP::AbstractSession.

◆ get() [2/2]

std::string ofx::HTTP::SimpleSession::get ( const std::string &  key) const
overridevirtual

Get the session data for a given key, or throw an exception.

Parameters
keyThe data key to get.
Exceptions
Poco::InvalidAccessExceptionif key does not exist.
Returns
the data value for the key.

Implements ofx::HTTP::AbstractSession.

◆ has()

bool ofx::HTTP::SimpleSession::has ( const std::string &  key) const
overridevirtual

Check to see if the provided key exists in the session data.

Parameters
keyThe data key to check.
Returns
true iff the key exists in the session data.

Implements ofx::HTTP::AbstractSession.

◆ put()

void ofx::HTTP::SimpleSession::put ( const std::string &  key,
const std::string &  value 
)
overridevirtual

Add (or replace) a key in the sesion data with the given value.

Parameters
keyThe data key to add.
valueThe data value to add for the given key.

Implements ofx::HTTP::AbstractSession.

◆ remove()

void ofx::HTTP::SimpleSession::remove ( const std::string &  key)
overridevirtual

Remove a key / value pair.

Parameters
keyThe key to remove.

Implements ofx::HTTP::AbstractSession.


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