magpie
Loading...
Searching...
No Matches
magpie::Cookie Class Reference

#include <Cookie.hpp>

Public Member Functions

 Cookie (std::string &&name, std::string &&value)
const std::string & getName () const
const std::string & getValue () const
const std::optional< size_t > & getMaxAge () const
bool isHttpOnly () const
bool isSecure () const
CookiesetHttpOnly ()
CookiesetSecure ()
CookiesetPath (std::string &&path)
CookiesetDomain (const std::string &domain)

Detailed Description

Used to represent both inbound and outbound cookies in a parsed format. When constructing a cookie in code, there's several builder functions that can be used to set other options.

Note
Expires is not supported at all even though it is a technically valid cookie field. This is because the field is considered bad practice by some accounts, and meeting the date format required for it in a sensible way is annoying. If you need expires, have you considered not needing it? You can get the, for all intents and purposes, exact same result with Max-Age.
See also
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie

Constructor & Destructor Documentation

◆ Cookie()

magpie::Cookie::Cookie ( std::string && name,
std::string && value )

Constructs a cookie.

Parameters
nameThe name of the cookie
valueThe value stored in the cookie
maxAgeThe max age of the cookie represented as seconds. If nullopt, no MaxAge is set.

Member Function Documentation

◆ setHttpOnly()

Cookie & magpie::Cookie::setHttpOnly ( )

Call this to set the HttpOnly flag in the cookie.

◆ setSecure()

Cookie & magpie::Cookie::setSecure ( )

Call this to set the Secure flag in the cookie.


The documentation for this class was generated from the following files:
  • src/magpie/application/formats/Cookie.hpp
  • src/magpie/application/formats/Cookie.cpp