Library: OSP/Web
Package: Web
Header: Poco/OSP/Web/WebSessionManager.h
Description
A WebSessionManager manages HTTP sessions using cookies.
The SessionManager is registered under the service name "osp.web.session".
Note that the application name (appName) specified in get() and create() can contain a domain name, separated by '@'. If a domain name is given, it is used to set the domain for the session cookie. Similarly, a path can be given, beginning with a slash.
For example, if the appName is sample@.appinf.com, then the browser will send the session cookie to all hosts with names in the appinf.com domain. If a domain is not given, the session cookie will only be available to the host that has originally set it.
Inheritance
Direct Base Classes: WebSessionService < Poco::Net::HTTPServerRequest >
All Base Classes: WebSessionService < Poco::Net::HTTPServerRequest >
Member Summary
Member Functions: addCookie, cookieDomain, cookieName, cookiePath, create, createSessionId, find, get, getCookiePersistence, getDefaultDomain, getDefaultPath, getId, isA, remove, setCookiePersistence, setDefaultDomain, setDefaultPath, type
Types
Ptr
typedef Poco::AutoPtr < WebSessionManager > Ptr;
Enumerations
CookiePersistence
COOKIE_TRANSIENT = 1
Session cookies are transient (go away when browser is closed).
Session cookies are persistent (kept in browser until they expire).
Constructors
WebSessionManager
Creates the SessionManager.
Destructor
~WebSessionManager
Destroys the SessionManager.
Member Functions
create
WebSession::Ptr create(
const std::string & appName,
const Poco::Net::HTTPServerRequest & request,
int expireSeconds,
BundleContext::Ptr pContext
);
find
WebSession::Ptr find(
const std::string & appName,
const Poco::Net::HTTPServerRequest & request
);
get
WebSession::Ptr get(
const std::string & appName,
const Poco::Net::HTTPServerRequest & request,
int expireSeconds,
BundleContext::Ptr pContext
);
getCookiePersistence
CookiePersistence getCookiePersistence() const;
Returns the cookie persistence.
getDefaultDomain
const std::string & getDefaultDomain() const;
Returns the default domain for the session cookie.
getDefaultPath
const std::string & getDefaultPath() const;
Returns the default path for the session cookie.
isA
virtual bool isA(
const std::type_info & otherType
) const;
remove
void remove(
WebSession::Ptr ptr
);
setCookiePersistence
void setCookiePersistence(
CookiePersistence persistence
);
Sets the cookie persistence, which controls whether session cookies are transient (go away when the browser is closed) or persistent (default).
setDefaultDomain
void setDefaultDomain(
const std::string & domain
);
Sets the default domain for the session cookie.
setDefaultPath
void setDefaultPath(
const std::string & path
);
Sets the default path for the session cookie.
type
virtual const std::type_info & type() const;
addCookie
void addCookie(
const std::string & appName,
const Poco::Net::HTTPServerRequest & request,
WebSession::Ptr ptrSes
);
cookieDomain
std::string cookieDomain(
const std::string & appName
);
cookieName
std::string cookieName(
const std::string & appName
);
cookiePath
std::string cookiePath(
const std::string & appName
);
createSessionId
std::string createSessionId(
const Poco::Net::HTTPServerRequest & request
);
getId
std::string getId(
const std::string & appName,
const Poco::Net::HTTPServerRequest & request
);
Variables
SERVICE_NAME
static const std::string SERVICE_NAME;