#include <cgicc/HTTPCookie.h>
Inheritance diagram for cgicc::HTTPCookie:
Public Member Functions | |
Overloaded Operators | |
bool | operator== (const HTTPCookie &cookie) const |
Compare two HTTPCookies for equality. | |
bool | operator!= (const HTTPCookie &cookie) const |
Compare two HTTPCookies for inequality. | |
Accessor Methods | |
std::string | getName () const |
Get the name of this cookie. | |
std::string | getValue () const |
Get the value of this cookie. | |
std::string | getComment () const |
Get the comment of this cookie. | |
std::string | getDomain () const |
Get the domain for which this cookie is valid. | |
unsigned long | getMaxAge () const |
Get the lifetime of this cookie, in seconds. | |
std::string | getPath () const |
Get the path of this cookie. | |
bool | isSecure () const |
Determine if this is a secure cookie. | |
Mutator Methods | |
void | setName (const std::string &name) |
Set the name of this cookie. | |
void | setValue (const std::string &value) |
Set the value of this cookie. | |
void | setComment (const std::string &comment) |
Set the comment of this cookie. | |
void | setDomain (const std::string &domain) |
Set the domain of this cookie. | |
void | setMaxAge (unsigned long maxAge) |
Set the lifetime of this cookie, in seconds. | |
void | setPath (const std::string &path) |
Set the path of this cookie. | |
void | setSecure (bool secure) |
Mark this cookie as secure or unsecure. | |
Inherited Methods | |
virtual void | render (std::ostream &out) const |
Write this object to a stream. |
An HTTP cookie is a way to maintain state between stateless HTTP requests. HTTP cookies consist of name/value pairs, with optional comments, domains, and expiration dates. Usually, you will add one or more HTTPCookie objects to the HTTP headers your script is returning. For example, to set a cookie called count
to 1
in a normal HTML document:
out << HTTPHTMLHeader().setCookie(HTTPCookie("count","1"));
Definition at line 58 of file HTTPCookie.h.
cgicc::HTTPCookie::HTTPCookie | ( | ) |
Default Constructor.
Create a new, empty HTTPCookie.
cgicc::HTTPCookie::HTTPCookie | ( | const std::string & | name, | |
const std::string & | value | |||
) |
Create a new HTTPCookie.
This is the most commonly-used constructor.
name | The name of the cookie. | |
value | The value of the cookie. |
cgicc::HTTPCookie::HTTPCookie | ( | const std::string & | name, | |
const std::string & | value, | |||
const std::string & | comment, | |||
const std::string & | domain, | |||
unsigned long | maxAge, | |||
const std::string & | path, | |||
bool | secure | |||
) |
Create a new fully-spefified HTTPCookie.
name | The name of the cookie. | |
value | The value of the cookie. | |
comment | Any comment associated with the cookie. | |
domain | The domain for which this cookie is valid- an empty string will use the hostname of the server which generated the cookie response. If specified, the domain must start with a period('.'). | |
maxAge | A number of seconds defining the lifetime of this cookie. A value of 0 indicates the cookie expires immediately. | |
path | The subset of URLS in a domain for which the cookie is valid, for example / | |
secure | Specifies whether this is a secure cookie. |
cgicc::HTTPCookie::HTTPCookie | ( | const HTTPCookie & | cookie | ) |
Copy constructor.
Set the name, value, comment, domain, age and path of this cookie to those of cookie
cookie | The HTTPCookie to copy. |
virtual cgicc::HTTPCookie::~HTTPCookie | ( | ) | [virtual] |
Destructor.
Delete this HTTPCookie
cgicc::HTTPCookie::HTTPCookie | ( | ) |
Default Constructor.
Create a new, empty HTTPCookie.
cgicc::HTTPCookie::HTTPCookie | ( | const std::string & | name, | |
const std::string & | value | |||
) |
Create a new HTTPCookie.
This is the most commonly-used constructor.
name | The name of the cookie. | |
value | The value of the cookie. |
cgicc::HTTPCookie::HTTPCookie | ( | const std::string & | name, | |
const std::string & | value, | |||
const std::string & | comment, | |||
const std::string & | domain, | |||
unsigned long | maxAge, | |||
const std::string & | path, | |||
bool | secure | |||
) |
Create a new fully-spefified HTTPCookie.
name | The name of the cookie. | |
value | The value of the cookie. | |
comment | Any comment associated with the cookie. | |
domain | The domain for which this cookie is valid- an empty string will use the hostname of the server which generated the cookie response. If specified, the domain must start with a period('.'). | |
maxAge | A number of seconds defining the lifetime of this cookie. A value of 0 indicates the cookie expires immediately. | |
path | The subset of URLS in a domain for which the cookie is valid, for example / | |
secure | Specifies whether this is a secure cookie. |
cgicc::HTTPCookie::HTTPCookie | ( | const HTTPCookie & | cookie | ) |
Copy constructor.
Set the name, value, comment, domain, age and path of this cookie to those of cookie
cookie | The HTTPCookie to copy. |
virtual cgicc::HTTPCookie::~HTTPCookie | ( | ) | [virtual] |
Destructor.
Delete this HTTPCookie
bool cgicc::HTTPCookie::operator== | ( | const HTTPCookie & | cookie | ) | const |
Compare two HTTPCookies for equality.
Two HTTPCookie objects are equal if their names, values, comments, domains, ages, and paths match.
cookie | The HTTPCookie to compare to this one |
bool cgicc::HTTPCookie::operator!= | ( | const HTTPCookie & | cookie | ) | const [inline] |
Compare two HTTPCookies for inequality.
Two HTTPCookie objects are equal if their names, values, comments, domains, ages, and paths match.
cookie | The HTTPCookie to compare to this one |
Definition at line 148 of file HTTPCookie.h.
std::string cgicc::HTTPCookie::getName | ( | ) | const [inline] |
Get the name of this cookie.
Definition at line 170 of file HTTPCookie.h.
std::string cgicc::HTTPCookie::getValue | ( | ) | const [inline] |
Get the value of this cookie.
Definition at line 179 of file HTTPCookie.h.
std::string cgicc::HTTPCookie::getComment | ( | ) | const [inline] |
Get the comment of this cookie.
Definition at line 188 of file HTTPCookie.h.
std::string cgicc::HTTPCookie::getDomain | ( | ) | const [inline] |
Get the domain for which this cookie is valid.
An empty string indicates the hostname of the server which generated the cookie response.
Definition at line 199 of file HTTPCookie.h.
unsigned long cgicc::HTTPCookie::getMaxAge | ( | ) | const [inline] |
Get the lifetime of this cookie, in seconds.
Definition at line 208 of file HTTPCookie.h.
std::string cgicc::HTTPCookie::getPath | ( | ) | const [inline] |
Get the path of this cookie.
This is the subset of URLS in a domain for which the cookie is valid, for example /
Definition at line 219 of file HTTPCookie.h.
bool cgicc::HTTPCookie::isSecure | ( | ) | const [inline] |
Determine if this is a secure cookie.
Definition at line 228 of file HTTPCookie.h.
void cgicc::HTTPCookie::setName | ( | const std::string & | name | ) | [inline] |
Set the name of this cookie.
name | The name of this cookie. |
Definition at line 243 of file HTTPCookie.h.
void cgicc::HTTPCookie::setValue | ( | const std::string & | value | ) | [inline] |
Set the value of this cookie.
value | The value of this cookie. |
Definition at line 252 of file HTTPCookie.h.
void cgicc::HTTPCookie::setComment | ( | const std::string & | comment | ) | [inline] |
Set the comment of this cookie.
comment | The comment of this cookie. |
Definition at line 261 of file HTTPCookie.h.
void cgicc::HTTPCookie::setDomain | ( | const std::string & | domain | ) | [inline] |
Set the domain of this cookie.
An empty string indicates the hostname of the server which generated the cookie response. If specified, the domain must start with a period('.').
domain | The domain of this cookie. |
Definition at line 273 of file HTTPCookie.h.
void cgicc::HTTPCookie::setMaxAge | ( | unsigned long | maxAge | ) | [inline] |
Set the lifetime of this cookie, in seconds.
A value of 0
indicated the cookie expires immediately
maxAge | The lifetime of this cookie, in seconds. |
Definition at line 283 of file HTTPCookie.h.
void cgicc::HTTPCookie::setPath | ( | const std::string & | path | ) | [inline] |
Set the path of this cookie.
This is the subset of URLS in a domain for which the cookie is valid, for example /
path | The path of this cookie. |
Definition at line 294 of file HTTPCookie.h.
void cgicc::HTTPCookie::setSecure | ( | bool | secure | ) | [inline] |
Mark this cookie as secure or unsecure.
secure | Whether this is a secure cookie. |
Definition at line 303 of file HTTPCookie.h.
virtual void cgicc::HTTPCookie::render | ( | std::ostream & | out | ) | const [virtual] |
Write this object to a stream.
Subclasses must implement this function.
out | The ostream to which to write. |
Implements cgicc::MStreamable.