Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress Servlet Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

rwsf::Cookie

Package:  Servlet


Base Class

Local Index

Members

Header File

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

Description

rwsf::Cookie represents an HTTP cookie. A cookie is a small piece of data sent from the server to the client. The client stores the cookie and returns it to the server with later requests. Cookies are typically used to store a small amount of state on the client. If the application requires little state, cookies can maintain the complete state of the application. Otherwise, the application will save the application state on the server and send the client a cookie with a unique token. On later requests, the client returns the token. The application uses the token to associate the saved state with the request. This class provides a simple API for working with cookies.

Each cookie consists of a name, a value, and a set of optional attributes. To add a cookie to a response, use the addCookie function of rwsf::HttpServletResponse. To access cookies in a request, use either the getCookie function or the getCookies function of rwsf::HttpServletRequest.

rwsf::Cookie provides support for both Version 0 (Netscape) and Version 1 (RFC 2109) cookies. However, due to portability concerns we recommend that you use Version 0 cookies (the default).

Note that HydraExpress includes classes that encapsulate the details of associating saved state with a client. For some applications, these classes can eliminate the need for working with cookies directly. See rwsf::HttpSession and related classes for details.

Table 1 lists methods that are either non-standard or not supported in this release.

Table 1: rwsf::Cookie Deviation from Servlet Specification

Member Description of Difference from Servlet Specification

constructors and assignment operator

added constructors and assignment operator

getExpires()

setExpires()

added methods for getting and setting expiration on version 0 cookies

clone()

not included in this implementation (functionality replaced by assignment operator and copy constructor).

Public Constructors

Cookie();
Cookie(const std::string& name);
Cookie(const std::string& name, const std::string& value);
Cookie(const Cookie& second);

Public Destructor

~Cookie();

Public Member Operators

Cookie& 
operator=(const Cookie& second);

Public Member Functions

std::string
getComment() const;
std::string
getDomain() const;
std::string
getExpires() const;
int
getMaxAge() const;
std::string
getName() const;
std::string
getPath() const;
bool
getSecure() const;
std::string
getValue() const;
int
getVersion() const;
void
setComment(const std::string& comment);
void
setDomain(const std::string& pattern);
void
setExpires(const std::string& expiry);
void
setMaxAge(int expiry);
void
setPath(const std::string& uri);
void 
setSecure(bool flag);
void 
setValue(const std::string& value);
void 
setVersion(int v);

See Also

rwsf::HttpSession

rwsf::HttpServletResponse

rwsf::HttpServletRequest



Previous fileTop of DocumentContentsIndex pageNext file

©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.