Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Poco::Net::HTTPCookie Class Reference

#include <HTTPCookie.h>

Public Types

enum  SameSite { SAME_SITE_NOT_SPECIFIED , SAME_SITE_NONE , SAME_SITE_LAX , SAME_SITE_STRICT }
 

Public Member Functions

 HTTPCookie ()
 
 HTTPCookie (const std::string &name)
 Creates an empty HTTPCookie.
 
 HTTPCookie (const NameValueCollection &nvc)
 
 HTTPCookie (const std::string &name, const std::string &value)
 Creates a cookie from the given NameValueCollection.
 
 HTTPCookie (const HTTPCookie &cookie)
 
 ~HTTPCookie ()
 Creates the HTTPCookie by copying another one.
 
HTTPCookieoperator= (const HTTPCookie &cookie)
 Destroys the HTTPCookie.
 
void setVersion (int version)
 Assigns a cookie.
 
int getVersion () const
 
void setName (const std::string &name)
 
const std::string & getName () const
 Sets the name of the cookie.
 
void setValue (const std::string &value)
 Returns the name of the cookie.
 
const std::string & getValue () const
 
void setComment (const std::string &comment)
 Returns the value of the cookie.
 
const std::string & getComment () const
 
void setDomain (const std::string &domain)
 Returns the comment for the cookie.
 
const std::string & getDomain () const
 Sets the domain for the cookie.
 
void setPath (const std::string &path)
 Returns the domain for the cookie.
 
void setPriority (const std::string &priority)
 Sets the path for the cookie.
 
const std::string & getPath () const
 Sets the priority for the cookie.
 
const std::string & getPriority () const
 Returns the path for the cookie.
 
void setSecure (bool secure)
 Returns the priority for the cookie.
 
bool getSecure () const
 
void setMaxAge (int maxAge)
 
int getMaxAge () const
 
void setHttpOnly (bool flag=true)
 
bool getHttpOnly () const
 Sets the HttpOnly flag for the cookie.
 
void setSameSite (SameSite value)
 Returns true iff the cookie's HttpOnly flag is set.
 
SameSite getSameSite () const
 Sets the cookie's SameSite attribute.
 
std::string toString () const
 Returns the cookie's SameSite attribute.
 

Static Public Member Functions

static std::string escape (const std::string &str)
 
static std::string unescape (const std::string &str)
 

Private Attributes

int _version
 
std::string _name
 
std::string _value
 
std::string _comment
 
std::string _domain
 
std::string _path
 
std::string _priority
 
bool _secure
 
int _maxAge
 
bool _httpOnly
 
SameSite _sameSite
 

Detailed Description

This class represents a HTTP Cookie.

A cookie is a small amount of information sent by a Web
server to a Web browser, saved by the browser, and later sent back
to the server. A cookie's value can uniquely identify a client, so
cookies are commonly used for session management.

A cookie has a name, a single value, and optional attributes such
as a comment, path and domain qualifiers, a maximum age, and a
version number.

This class supports both the Version 0 (by Netscape) and Version 1
(by RFC 2109) cookie specifications. By default, cookies are created
using Version 0 to ensure the best interoperability. 

Definition at line 31 of file HTTPCookie.h.

Member Enumeration Documentation

◆ SameSite

Enumerator
SAME_SITE_NOT_SPECIFIED 
SAME_SITE_NONE 
SAME_SITE_LAX 
SAME_SITE_STRICT 

Definition at line 48 of file HTTPCookie.h.

Constructor & Destructor Documentation

◆ HTTPCookie() [1/5]

Poco::Net::HTTPCookie::HTTPCookie ( )

◆ HTTPCookie() [2/5]

Poco::Net::HTTPCookie::HTTPCookie ( const std::string & name)
explicit

Creates an empty HTTPCookie.

◆ HTTPCookie() [3/5]

Poco::Net::HTTPCookie::HTTPCookie ( const NameValueCollection & nvc)
explicit

Creates a cookie with the given name. The cookie never expires.

◆ HTTPCookie() [4/5]

Poco::Net::HTTPCookie::HTTPCookie ( const std::string & name,
const std::string & value )

Creates a cookie from the given NameValueCollection.

◆ HTTPCookie() [5/5]

Poco::Net::HTTPCookie::HTTPCookie ( const HTTPCookie & cookie)

Creates a cookie with the given name and value. The cookie never expires.

Note: If value contains whitespace or non-alphanumeric characters, the value should be escaped by calling escape() before passing it to the constructor.

◆ ~HTTPCookie()

Poco::Net::HTTPCookie::~HTTPCookie ( )

Creates the HTTPCookie by copying another one.

Member Function Documentation

◆ escape()

static std::string Poco::Net::HTTPCookie::escape ( const std::string & str)
static

Returns a string representation of the cookie, suitable for use in a Set-Cookie header.

◆ getComment()

const std::string & Poco::Net::HTTPCookie::getComment ( ) const
inline

Sets the comment for the cookie.

Comments are only supported for version 1 cookies.

Definition at line 242 of file HTTPCookie.h.

◆ getDomain()

const std::string & Poco::Net::HTTPCookie::getDomain ( ) const
inline

Sets the domain for the cookie.

Definition at line 248 of file HTTPCookie.h.

◆ getHttpOnly()

bool Poco::Net::HTTPCookie::getHttpOnly ( ) const
inline

Sets the HttpOnly flag for the cookie.

Definition at line 278 of file HTTPCookie.h.

◆ getMaxAge()

int Poco::Net::HTTPCookie::getMaxAge ( ) const
inline

Sets the maximum age in seconds for the cookie.

A value of -1 (default) causes the cookie to become a session cookie, which will be deleted when the browser window is closed.

A value of 0 deletes the cookie on the client.

Definition at line 272 of file HTTPCookie.h.

◆ getName()

const std::string & Poco::Net::HTTPCookie::getName ( ) const
inline

Sets the name of the cookie.

Definition at line 230 of file HTTPCookie.h.

◆ getPath()

const std::string & Poco::Net::HTTPCookie::getPath ( ) const
inline

Sets the priority for the cookie.

Definition at line 254 of file HTTPCookie.h.

◆ getPriority()

const std::string & Poco::Net::HTTPCookie::getPriority ( ) const
inline

Returns the path for the cookie.

Definition at line 260 of file HTTPCookie.h.

◆ getSameSite()

HTTPCookie::SameSite Poco::Net::HTTPCookie::getSameSite ( ) const
inline

Sets the cookie's SameSite attribute.

Definition at line 284 of file HTTPCookie.h.

◆ getSecure()

bool Poco::Net::HTTPCookie::getSecure ( ) const
inline

Sets the value of the secure flag for the cookie.

Definition at line 266 of file HTTPCookie.h.

◆ getValue()

const std::string & Poco::Net::HTTPCookie::getValue ( ) const
inline

Sets the value of the cookie.

According to the cookie specification, the size of the value should not exceed 4 Kbytes.

Note: If value contains whitespace or non-alphanumeric characters, the value should be escaped by calling escape() prior to passing it to setName().

Definition at line 236 of file HTTPCookie.h.

◆ getVersion()

int Poco::Net::HTTPCookie::getVersion ( ) const
inline

Sets the version of the cookie.

Version must be either 0 (denoting a Netscape cookie) or 1 (denoting a RFC 2109 cookie).

Definition at line 224 of file HTTPCookie.h.

◆ operator=()

HTTPCookie & Poco::Net::HTTPCookie::operator= ( const HTTPCookie & cookie)

Destroys the HTTPCookie.

◆ setComment()

void Poco::Net::HTTPCookie::setComment ( const std::string & comment)

Returns the value of the cookie.

◆ setDomain()

void Poco::Net::HTTPCookie::setDomain ( const std::string & domain)

Returns the comment for the cookie.

◆ setHttpOnly()

void Poco::Net::HTTPCookie::setHttpOnly ( bool flag = true)

Returns the maximum age in seconds for the cookie.

◆ setMaxAge()

void Poco::Net::HTTPCookie::setMaxAge ( int maxAge)

Returns the value of the secure flag for the cookie.

◆ setName()

void Poco::Net::HTTPCookie::setName ( const std::string & name)

Returns the version of the cookie, which is either 0 or 1.

◆ setPath()

void Poco::Net::HTTPCookie::setPath ( const std::string & path)

Returns the domain for the cookie.

◆ setPriority()

void Poco::Net::HTTPCookie::setPriority ( const std::string & priority)

Sets the path for the cookie.

◆ setSameSite()

void Poco::Net::HTTPCookie::setSameSite ( SameSite value)

Returns true iff the cookie's HttpOnly flag is set.

◆ setSecure()

void Poco::Net::HTTPCookie::setSecure ( bool secure)

Returns the priority for the cookie.

◆ setValue()

void Poco::Net::HTTPCookie::setValue ( const std::string & value)

Returns the name of the cookie.

◆ setVersion()

void Poco::Net::HTTPCookie::setVersion ( int version)

Assigns a cookie.

◆ toString()

std::string Poco::Net::HTTPCookie::toString ( ) const

Returns the cookie's SameSite attribute.

◆ unescape()

static std::string Poco::Net::HTTPCookie::unescape ( const std::string & str)
static

Escapes the given string by replacing all non-alphanumeric characters with escape sequences in the form xx, where xx is the hexadecimal character code.

The following characters will be replaced with escape sequences:

  • percent sign %
  • less-than and greater-than < and >
  • curly brackets { and }
  • square brackets [ and ]
  • parenthesis ( and )
  • solidus /
  • vertical line |
  • reverse solidus (backslash /)
  • quotation mark "
  • apostrophe '
  • circumflex accent ^
  • grave accent `
  • comma and semicolon , and ;
  • whitespace and control characters

Member Data Documentation

◆ _comment

std::string Poco::Net::HTTPCookie::_comment
private

Definition at line 210 of file HTTPCookie.h.

◆ _domain

std::string Poco::Net::HTTPCookie::_domain
private

Definition at line 211 of file HTTPCookie.h.

◆ _httpOnly

bool Poco::Net::HTTPCookie::_httpOnly
private

Definition at line 216 of file HTTPCookie.h.

◆ _maxAge

int Poco::Net::HTTPCookie::_maxAge
private

Definition at line 215 of file HTTPCookie.h.

◆ _name

std::string Poco::Net::HTTPCookie::_name
private

Definition at line 208 of file HTTPCookie.h.

◆ _path

std::string Poco::Net::HTTPCookie::_path
private

Definition at line 212 of file HTTPCookie.h.

◆ _priority

std::string Poco::Net::HTTPCookie::_priority
private

Definition at line 213 of file HTTPCookie.h.

◆ _sameSite

SameSite Poco::Net::HTTPCookie::_sameSite
private

Definition at line 217 of file HTTPCookie.h.

◆ _secure

bool Poco::Net::HTTPCookie::_secure
private

Definition at line 214 of file HTTPCookie.h.

◆ _value

std::string Poco::Net::HTTPCookie::_value
private

Definition at line 209 of file HTTPCookie.h.

◆ _version

int Poco::Net::HTTPCookie::_version
private

Unescapes the given string by replacing all escape sequences in the form xx with the respective characters.

Definition at line 207 of file HTTPCookie.h.


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