8 #ifndef MOD_SERVLET_COOKIE_H
9 #define MOD_SERVLET_COOKIE_H
70 cookie(
const std::string &name,
const std::string &value) : _name{name}, _value{value} {}
82 cookie(std::string &&name, std::string &&value) : _name{std::move(name)}, _value{std::move(value)} {}
94 cookie(std::string &&name,
const std::string &value) : _name{std::move(name)}, _value{value} {}
106 cookie(
const std::string &name, std::string &&value) : _name{name}, _value{std::move(value)} {}
143 const std::
string &
get_name()
const {
return _name; }
192 const std::string &
get_path()
const {
return _path; }
239 void set_value(
const std::string &value) { _value = value; }
250 void set_value(std::string &&value) { _value = std::move(value); }
261 void set_comment(
const std::string &comment) { _comment = comment; }
273 void set_comment(std::string &&comment) { _comment = std::move(comment); }
288 void set_domain(
const std::string &domain) { _domain = domain; }
300 void set_domain(std::string &&domain) { _domain = std::move(domain); }
336 void set_path(
const std::string &path) { _path = path; }
348 void set_path(std::string &&path) { _path = std::move(path); }
397 std::string _comment;
402 bool _secure =
false;
404 bool _http_only =
false;
409 #endif // MOD_SERVLET_COOKIE_H
void set_comment(std::string &&comment)
Specifies a comment that describes a cookie's purpose.
Definition: cookie.h:273
const std::string & get_value() const
Returns the value of the cookie.
Definition: cookie.h:152
cookie(std::string &&name, std::string &&value)
Constructs a cookie with a specified name and value.
Definition: cookie.h:82
void set_comment(const std::string &comment)
Specifies a comment that describes a cookie's purpose.
Definition: cookie.h:261
cookie(std::string &&name, const std::string &value)
Constructs a cookie with a specified name and value.
Definition: cookie.h:94
long get_max_age() const
Returns the maximum age of the cookie, specified in seconds, By default, -1 indicating the cookie wil...
Definition: cookie.h:182
cookie(const std::string &name, const std::string &value)
Constructs a cookie with a specified name and value.
Definition: cookie.h:70
bool is_secure() const
Returns true if the browser is sending cookies only over a secure protocol, or false if the browser c...
Definition: cookie.h:203
void set_value(std::string &&value)
Assigns a new value to a cookie after the cookie is created.
Definition: cookie.h:250
int get_version() const
Returns the version of the protocol this cookie complies with.
Definition: cookie.h:215
void set_domain(std::string &&domain)
Specifies the domain within which this cookie should be presented.
Definition: cookie.h:300
void set_secure(bool secure)
Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.
Definition: cookie.h:361
void set_domain(const std::string &domain)
Specifies the domain within which this cookie should be presented.
Definition: cookie.h:288
Creates a cookie, a small amount of information sent by a servlet to a Web browser, saved by the browser, and later sent back to the server.
Definition: cookie.h:46
const std::string & get_name() const
Returns the name of the cookie.
Definition: cookie.h:143
~cookie() noexcept=default
Destructor.
std::string to_string() const
Converts this cookie into its string representation.
void set_max_age(long max_age)
Sets the maximum age of the cookie in seconds.
Definition: cookie.h:318
bool is_http_only() const
Gets the flag that controls if this cookie will be hidden from scripts on the client side...
Definition: cookie.h:224
cookie & operator=(const cookie &c)=default
Copy assignment operator.
void set_version(int version)
Sets the version of the cookie protocol this cookie complies with.
Definition: cookie.h:375
void set_path(std::string &&path)
Specifies a path for the cookie to which the client should return the cookie.
Definition: cookie.h:348
void set_value(const std::string &value)
Assigns a new value to a cookie after the cookie is created.
Definition: cookie.h:239
cookie(const std::string &name, std::string &&value)
Constructs a cookie with a specified name and value.
Definition: cookie.h:106
void set_path(const std::string &path)
Specifies a path for the cookie to which the client should return the cookie.
Definition: cookie.h:336
const std::string & get_comment() const
Returns the comment describing the purpose of this cookie, or empty string if the cookie has no comme...
Definition: cookie.h:162
void set_http_only(bool http_only)
Sets the flag that controls if this cookie will be hidden from scripts on the client side...
Definition: cookie.h:383
const std::string & get_domain() const
Returns the domain name set for this cookie.
Definition: cookie.h:171
const std::string & get_path() const
Returns the path on the server to which the browser returns this cookie.
Definition: cookie.h:192