HydraExpress™ C++ API Reference Guide

Product Documentation:
   HydraExpress C++
Documentation Home
List of all members | Public Member Functions
rwsf::HttpSession Class Reference

Stores user specific information and identifies a user across multiple requests or site visits. More...

#include <rwsf/servlet/http/HttpSession.h>

Inheritance diagram for rwsf::HttpSession:
rwsf::HandleBase

Public Member Functions

 HttpSession ()
 
 HttpSession (const HttpSession &second)
 
virtual ~HttpSession ()
 
rwsf::Attribute getAttribute (const std::string &name) const
 
rwsf::Enumeration< std::string > getAttributeNames () const
 
rwsf::DateTime getCreationTime () const
 
std::string getId () const
 
rwsf::DateTime getLastAccessedTime () const
 
int getMaxInactiveInterval () const
 
rwsf::ServletContext getServletContext () const
 
void invalidate ()
 
bool isNew () const
 
virtual bool isValid () const
 
HttpSessionoperator= (const HttpSession &s)
 
rwsf::Attribute removeAttribute (const std::string &name)
 
void setAttribute (const std::string &name, const rwsf::Attribute &value)
 
void setFromCookie ()
 
void setFromURL ()
 
void setMaxInactiveInterval (int interval)
 
- Public Member Functions inherited from rwsf::HandleBase
bool isValid (void) const
 
bool operator!= (const HandleBase &second) const
 
bool operator== (const HandleBase &second) const
 

Additional Inherited Members

- Protected Member Functions inherited from rwsf::HandleBase
 HandleBase (void)
 
 HandleBase (StaticCtor)
 
 HandleBase (BodyBase *body)
 
 HandleBase (const HandleBase &second)
 
virtual ~HandleBase (void)
 
BodyBase & body (void) const
 
HandleBaseoperator= (const HandleBase &second)
 

Detailed Description

rwsf::HttpSession provides a convenient interface for maintaining state across HTTP requests. The class allows access to information about a session, such as when the session was created and when the session was last accessed.

Each session object contains a unique session ID. The session ID is stored in a client's browser using either a cookie or by rewriting the URL to include the session ID. When the client submits a new request to the servlet, the Agent uses the session ID to automatically associate the saved session with the new request.

A session represents state as a collection of rwsf::Attribute objects. Each attribute is associated with an attribute name.

A listener can register interest in session events, such as when new attributes are added, or when a session is invalidated or times out. For more information on receiving session events, see rwsf::HttpSessionListener.

The behavior of the following functions are inconsistent with or not defined in the Java Servlet Specification v2.3.

setFromCookie() Added method
setFromURL() Added method

Constructor & Destructor Documentation

rwsf::HttpSession::HttpSession ( )

Creates an empty, invalid session object. Use rwsf::HttpServletRequest::getSession() to create a valid session.

rwsf::HttpSession::HttpSession ( const HttpSession second)

Creates a new HttpSession handle to the body instance of second.

virtual rwsf::HttpSession::~HttpSession ( )
virtual

Detaches from the current body (if any), decrements its reference count, and deletes it if there are no other references.

Member Function Documentation

rwsf::Attribute rwsf::HttpSession::getAttribute ( const std::string &  name) const

Returns the specified attribute. Attribute name comparisons are case sensitive. If the named attribute is not found, returns an empty attribute.

rwsf::Enumeration<std::string> rwsf::HttpSession::getAttributeNames ( ) const

Returns an enumeration of all attribute names in this session. If there are no attributes, returns an empty enumeration.

rwsf::DateTime rwsf::HttpSession::getCreationTime ( ) const

Returns the time that this session was created.

std::string rwsf::HttpSession::getId ( ) const

Returns the unique ID for this session. The Agent guarantees that each session ID is unique for the Agent.

rwsf::DateTime rwsf::HttpSession::getLastAccessedTime ( ) const

Returns the last time that a client sent a request associated with this session. The time is updated only when a client sends a request to the Agent with this session.

int rwsf::HttpSession::getMaxInactiveInterval ( ) const

Returns the maximum time interval (in seconds) that this session can remain inactive. If this session is inactive longer than this value allows, the Agent invalidates the session. If the interval is negative, this session will never time out.

rwsf::ServletContext rwsf::HttpSession::getServletContext ( ) const

Returns the context that created this session.

void rwsf::HttpSession::invalidate ( )

Invalidates this session and removes any attributes associated with it. When the session is invalidated, all rwsf::HttpSessionListener objects attached to the rwsf::ServletContext are notified that this session has been invalidated.

bool rwsf::HttpSession::isNew ( ) const

Returns true if the client has not yet returned the session identifier to the Agent. Otherwise, returns false.

virtual bool rwsf::HttpSession::isValid ( ) const
virtual

Returns true if this session object has a valid body and has a valid session ID.

HttpSession& rwsf::HttpSession::operator= ( const HttpSession s)

Associates this handle with the body instance of s. Returns a reference to self.

rwsf::Attribute rwsf::HttpSession::removeAttribute ( const std::string &  name)

Removes the named attribute from this session and returns the attribute. If the named attribute is not found, this method returns an empty attribute.

void rwsf::HttpSession::setAttribute ( const std::string &  name,
const rwsf::Attribute value 
)

Stores the named attribute in this session. Attributes store servlet state between client invocations.

void rwsf::HttpSession::setFromCookie ( )

Sets this session to use cookies when sending session information back to the client.

void rwsf::HttpSession::setFromURL ( )

Sets this session to use URL rewriting when sending session information back to the client. This function has no effect if the client has already used a cookie to return the session identifier.

void rwsf::HttpSession::setMaxInactiveInterval ( int  interval)

Sets the session lifetime to interval seconds. If this session remains inactive longer than interval, the Agent invalidates the session. If interval is negative, this session will never time out.

Copyright © 2019 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is registered trademark of Rogue Wave Software, Inc. in the United States and other countries, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.