List of all members
cgicc::HTTPCookie Class Reference

An HTTP cookie. More...

`#include <cgicc/HTTPCookie.h>`

Inheritance diagram for cgicc::HTTPCookie:

## Public Member Functions
Constructors and Destructor
| HTTPCookie ()
| Default Constructor. More...
| HTTPCookie (const std::string &name, const std::string &value)
| Create a new HTTPCookie. More...
| 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. More...
| HTTPCookie (const HTTPCookie &cookie)
| Copy constructor. More...
virtual | ~HTTPCookie ()
| Destructor. More...
Overloaded Operators
bool | operator== (const HTTPCookie &cookie) const
| Compare two HTTPCookies for equality. More...
bool | operator!= (const HTTPCookie &cookie) const
| Compare two HTTPCookies for inequality. More...
Accessor Methods
void | remove ()
| Mark this cookie as secure or unsecure. More...
void | setRemoved (bool removed)
| Mark this cookie as secure or unsecure. More...
bool | isRemoved () const
| Determine if this is a removed cookie. More...
| HTTPCookie (const std::string &name, const std::string &domain, const std::string &path, bool secure)
| Create a new partially-spefified HTTPCookie for deletion. More...
std::string | getName () const
| Get the name of this cookie. More...
std::string | getValue () const
| Get the value of this cookie. More...
std::string | getComment () const
| Get the comment of this cookie. More...
std::string | getDomain () const
| Get the domain for which this cookie is valid. More...
unsigned long | getMaxAge () const
| Get the lifetime of this cookie, in seconds. More...
std::string | getPath () const
| Get the path of this cookie. More...
bool | isSecure () const
| Determine if this is a secure cookie. More...
Mutator Methods
void | setName (const std::string &name)
| Set the name of this cookie. More...
void | setValue (const std::string &value)
| Set the value of this cookie. More...
void | setComment (const std::string &comment)
| Set the comment of this cookie. More...
void | setDomain (const std::string &domain)
| Set the domain of this cookie. More...
void | setMaxAge (unsigned long maxAge)
| Set the lifetime of this cookie, in seconds. More...
void | setPath (const std::string &path)
| Set the path of this cookie. More...
void | setSecure (bool secure)
| Mark this cookie as secure or unsecure. More...
Public Member Functions inherited from cgicc::MStreamable
| MStreamable ()
| Empty constructor. More...
virtual | ~MStreamable ()
| Empty destructor. More...
virtual void | render (std::ostream &out) const =0
| Write this object to a stream. More...

## Inherited Methods
virtual void | render (std::ostream &out) const
| Write this object to a stream. More...

## Detailed Description

An HTTP cookie.

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"));
cgicc::HTTPCookie::HTTPCookie
HTTPCookie()
Default Constructor.

Definition at line 58 of file HTTPCookie.h.

## Constructor & Destructor Documentation

## ◆ HTTPCookie() [1/5]

cgicc::HTTPCookie::HTTPCookie | ( |  | ) |

Default Constructor.

Create a new, empty HTTPCookie.

## ◆ HTTPCookie() [2/5]

cgicc::HTTPCookie::HTTPCookie | ( | const std::string & | name,
|  | const std::string & | value
| ) |  |

Create a new HTTPCookie.

This is the most commonly-used constructor.

Parameters

  name | The name of the cookie.
  value | The value of the cookie.

## ◆ HTTPCookie() [3/5]

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.

Parameters

  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.

## ◆ HTTPCookie() [4/5]

cgicc::HTTPCookie::HTTPCookie | ( | const HTTPCookie & | cookie | ) |

Copy constructor.

Set the name, value, comment, domain, age and path of this cookie to those of `cookie`

Parameters

  cookie | The HTTPCookie to copy.

## ◆ ~HTTPCookie()

virtual cgicc::HTTPCookie::~HTTPCookie | ( |  | ) |
| virtual

Destructor.

Delete this HTTPCookie

## ◆ HTTPCookie() [5/5]

cgicc::HTTPCookie::HTTPCookie | ( | const std::string & | name,
|  | const std::string & | domain,
|  | const std::string & | path,
|  | bool | secure
| ) |  |

Create a new partially-spefified HTTPCookie for deletion.

Parameters

  name | The name of 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('.').
  path | The subset of URLS in a domain for which the cookie is valid, for example `/`
  secure | Specifies whether this is a secure cookie.

## Member Function Documentation

## ◆ getComment()

std::string cgicc::HTTPCookie::getComment | ( |  | ) | const
| inline

Get the comment of this cookie.

Returns
  The comment of this cookie.

Definition at line 229 of file HTTPCookie.h.

## ◆ getDomain()

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.

Returns
  The domain of this cookie, or "" if none.

Definition at line 240 of file HTTPCookie.h.

## ◆ getMaxAge()

unsigned long cgicc::HTTPCookie::getMaxAge | ( |  | ) | const
| inline

Get the lifetime of this cookie, in seconds.

Returns
  The lifetime of this cookie, or 0 if none.

Definition at line 249 of file HTTPCookie.h.

## ◆ getName()

std::string cgicc::HTTPCookie::getName | ( |  | ) | const
| inline

Get the name of this cookie.

Returns
  The name of this cookie.

Definition at line 211 of file HTTPCookie.h.

Referenced by CardGameTools::getNUMCookie().

## ◆ getPath()

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 `/`

Returns
  The path of this cookie, or "" if none.

Definition at line 260 of file HTTPCookie.h.

## ◆ getValue()

std::string cgicc::HTTPCookie::getValue | ( |  | ) | const
| inline

Get the value of this cookie.

Returns
  The value of this cookie.

Definition at line 220 of file HTTPCookie.h.

## ◆ isRemoved()

bool cgicc::HTTPCookie::isRemoved | ( |  | ) | const
| inline

Determine if this is a removed cookie.

Returns
  True if this cookie is removed, false if not.

Definition at line 186 of file HTTPCookie.h.

## ◆ isSecure()

bool cgicc::HTTPCookie::isSecure | ( |  | ) | const
| inline

Determine if this is a secure cookie.

Returns
  True if this cookie is secure, false if not.

Definition at line 269 of file HTTPCookie.h.

## ◆ operator!=()

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.

Parameters

  cookie | The HTTPCookie to compare to this one

Returns
  false if the two HTTPCookies are equal, true otherwise.

Definition at line 148 of file HTTPCookie.h.

## ◆ operator==()

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.

Parameters

  cookie | The HTTPCookie to compare to this one

Returns
  true if the two HTTPCookies are equal, false otherwise.

## ◆ remove()

void cgicc::HTTPCookie::remove | ( |  | ) |
| inline

Mark this cookie as secure or unsecure.

Definition at line 169 of file HTTPCookie.h.

## ◆ render()

virtual void cgicc::HTTPCookie::render | ( | std::ostream & | out | ) | const
| virtual

Write this object to a stream.

Subclasses must implement this function.

Parameters

  out | The ostream to which to write.

Implements cgicc::MStreamable.

## ◆ setComment()

void cgicc::HTTPCookie::setComment | ( | const std::string & | comment | ) |
| inline

Set the comment of this cookie.

Parameters

  comment | The comment of this cookie.

Definition at line 302 of file HTTPCookie.h.

## ◆ setDomain()

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('.').

Parameters

  domain | The domain of this cookie.

Definition at line 314 of file HTTPCookie.h.

## ◆ setMaxAge()

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

Parameters

  maxAge | The lifetime of this cookie, in seconds.

Definition at line 324 of file HTTPCookie.h.

## ◆ setName()

void cgicc::HTTPCookie::setName | ( | const std::string & | name | ) |
| inline

Set the name of this cookie.

Parameters

  name | The name of this cookie.

Definition at line 284 of file HTTPCookie.h.

## ◆ setPath()

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 `/`

Parameters

  path | The path of this cookie.

Definition at line 335 of file HTTPCookie.h.

## ◆ setRemoved()

void cgicc::HTTPCookie::setRemoved | ( | bool | removed | ) |
| inline

Mark this cookie as secure or unsecure.

Parameters

  removed | Set removed status

Definition at line 178 of file HTTPCookie.h.

## ◆ setSecure()

void cgicc::HTTPCookie::setSecure | ( | bool | secure | ) |
| inline

Mark this cookie as secure or unsecure.

Parameters

  secure | Whether this is a secure cookie.

Definition at line 344 of file HTTPCookie.h.

## ◆ setValue()

void cgicc::HTTPCookie::setValue | ( | const std::string & | value | ) |
| inline

Set the value of this cookie.

Parameters

  value | The value of this cookie.

Definition at line 293 of file HTTPCookie.h.

The documentation for this class was generated from the following file:

- HTTPCookie.h