roar
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
Roar::Cookie Class Reference

#include <cookie.hpp>

Collaboration diagram for Roar::Cookie:

Public Member Functions

 Cookie ()
 
 Cookie (std::string const &name, std::string const &value)
 
CookiesetName (std::string const &name)
 
CookiesetValue (std::string const &value)
 
CookiesetExpiry (date const &expires)
 
CookiemakeSessionCookie ()
 
CookiesetSecure (bool secure)
 
CookiesetHttpOnly (bool http_only)
 
CookiesetDomain (std::string const &domain)
 
CookiesetPath (std::string const &path)
 
CookiesetMaxAge (uint64_t age)
 
CookiesetSameSite (std::string const &same_site)
 
std::string getName () const
 
std::string getValue () const
 
bool isSecure () const
 
bool isHttpOnly () const
 
std::string getPath () const
 
std::string getDomain () const
 
uint64_t getMaxAge () const
 
std::string getSameSite () const
 
std::string toSetCookieString () const
 

Static Public Member Functions

static std::unordered_map< std::string, std::string > parseCookies (std::string const &cookieHeaderEntry)
 

Private Attributes

std::string name_
 
std::string value_
 
std::string domain_
 
std::string path_
 
std::string sameSite_
 
boost::optional< dateexpires_
 
uint64_t maxAge_
 
bool secure_
 
bool httpOnly_
 

Detailed Description

A Cookie helper class that contains Cookie data and provides utilitarian functions.

Constructor & Destructor Documentation

◆ Cookie() [1/2]

Roar::Cookie::Cookie ( )
explicit

Creates a fresh session Cookie.

◆ Cookie() [2/2]

Roar::Cookie::Cookie ( std::string const &  name,
std::string const &  value 
)
explicit

Create a Cookie, setting only name and value.

Member Function Documentation

◆ getDomain()

std::string Roar::Cookie::getDomain ( ) const

Returns the domain attribution.

◆ getMaxAge()

uint64_t Roar::Cookie::getMaxAge ( ) const

Get the maximum age of the Cookie.

◆ getName()

std::string Roar::Cookie::getName ( ) const

Returns the Cookie name.

◆ getPath()

std::string Roar::Cookie::getPath ( ) const

Returns the path attribution.

◆ getSameSite()

std::string Roar::Cookie::getSameSite ( ) const

◆ getValue()

std::string Roar::Cookie::getValue ( ) const

Returns the Cookie value.

◆ isHttpOnly()

bool Roar::Cookie::isHttpOnly ( ) const

Returns whether the Cookie is "HttpOnly" or not.

◆ isSecure()

bool Roar::Cookie::isSecure ( ) const

Returns whether the Cookie is secure or not.

◆ makeSessionCookie()

Cookie & Roar::Cookie::makeSessionCookie ( )

Removes the expiration date. All cookies are session cookies after creation, so no need to call this for fresh cookies.

◆ parseCookies()

std::unordered_map< std::string, std::string > Roar::Cookie::parseCookies ( std::string const &  cookieHeaderEntry)
static

Parses a Cookie request header entry and makes a Cookie from it.

◆ setDomain()

Cookie & Roar::Cookie::setDomain ( std::string const &  domain)

Set the Domain attribute of the Cookie.

◆ setExpiry()

Cookie & Roar::Cookie::setExpiry ( date const &  expires)

Set Cookie expiration date.

◆ setHttpOnly()

Cookie & Roar::Cookie::setHttpOnly ( bool  http_only)

Set whether or not, the Cookie shall be accessible by scripting languages. This feature implemented by some browsers reduces XSS vulnerability.

Parameters
http_onlyThe Cookie will not be accessible by JavaScript etc when true.

◆ setMaxAge()

Cookie & Roar::Cookie::setMaxAge ( uint64_t  age)

Set the max age attribute of the cookie.

◆ setName()

Cookie & Roar::Cookie::setName ( std::string const &  name)

Set Cookie name.

◆ setPath()

Cookie & Roar::Cookie::setPath ( std::string const &  path)

Set the path on which the Cookie shall be accessible from.

◆ setSameSite()

Cookie & Roar::Cookie::setSameSite ( std::string const &  same_site)

◆ setSecure()

Cookie & Roar::Cookie::setSecure ( bool  secure)

Set whether or not the Cookie shall be a secure Cookie.

Parameters
secureThe Cookie will only be used over HTTPS if true.

◆ setValue()

Cookie & Roar::Cookie::setValue ( std::string const &  value)

Set Cookie value.

◆ toSetCookieString()

std::string Roar::Cookie::toSetCookieString ( ) const

Creates a set Cookie string.

Member Data Documentation

◆ domain_

std::string Roar::Cookie::domain_
private

◆ expires_

boost::optional<date> Roar::Cookie::expires_
private

◆ httpOnly_

bool Roar::Cookie::httpOnly_
private

◆ maxAge_

uint64_t Roar::Cookie::maxAge_
private

◆ name_

std::string Roar::Cookie::name_
private

◆ path_

std::string Roar::Cookie::path_
private

◆ sameSite_

std::string Roar::Cookie::sameSite_
private

◆ secure_

bool Roar::Cookie::secure_
private

◆ value_

std::string Roar::Cookie::value_
private

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