rwsf::HttpSessionrwsf::HandleBase
#include rwsf/servlet/http/HttpSession.h
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 following table lists methods that are either non-standard or not supported at this release.
setFromCookie() |
added method |
setFromURL() |
added method |
HttpSession();
Creates an empty, invalid session object. Use rwsf::HttpServletRequest::getSession() to create a valid session.
HttpSession(const HttpSession & second);
Attaches to and increments the reference count on second's body.
virtual ~HttpSession();
Detaches from the current body (if any), decrements its reference count, deletes it if there are no other references.
rwsf::Attribute 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 > getAttributeNames() const;
Returns an enumeration of all attribute names in this session. If there are no attributes, returns an empty enumeration.
rwsf::DateTime getCreationTime() const;
Returns the time that this session was created.
std::string getId() const;
Returns the unique ID for this session. The Agent guarantees that each session ID is unique for the Agent.
rwsf::DateTime getLastAccessedTime() const;
Returns the last time that a client sent a request associated with this session. This time is only updated when a client sends a request to the Agent with this session.
int 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 getServletContext() const;
Returns the context that created this session.
void invalidate();
Invalidates this session and removes any attributes associated with this session. When the session is invalidated, all rwsf::HttpSessionListener objects attached to the rwsf::ServletContext are notified that this session has been invalidated.
bool isNew() const;
Returns true if the client has not yet returned the session identifier to the Agent. Otherwise, returns false.
bool isValid() const;
Reimplements method in rwsf::HandleBase
Base class documentation:
Returns true if this handle points to a valid body instance, and false otherwise.
Implementation documentation:
Returns true if this session object has a valid body and has a valid session ID.
rwsf::Attribute 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 setAttribute(const std::string & name, const rwsf::Attribute & value);
Stores the named attribute in this session. Attributes store servlet state between client invocations.
void setFromCookie();
Sets this session to use cookies when sending session information back to the client.
void 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 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.
HttpSession & operator=(const HttpSession & s);
Detaches from the current body (if any), decrements its reference count, deletes it if there are no other references, and then attaches to second 's body and increments its reference count.
© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.