QtWebApp
|
HTTP cookie as defined in RFC 2109. More...
#include <httpcookie.h>
Public Member Functions | |
HttpCookie () | |
Creates an empty cookie. | |
HttpCookie (const QByteArray name, const QByteArray value, const int maxAge, const QByteArray path="/", const QByteArray comment=QByteArray(), const QByteArray domain=QByteArray(), const bool secure=false, const bool httpOnly=false, const QByteArray sameSite=QByteArray()) | |
Create a cookie and set name/value pair. More... | |
HttpCookie (const QByteArray source) | |
Create a cookie from a string. More... | |
QByteArray | toByteArray () const |
Convert this cookie to a string that may be used in a Set-Cookie header. | |
void | setName (const QByteArray name) |
Set the name of this cookie. | |
void | setValue (const QByteArray value) |
Set the value of this cookie. | |
void | setComment (const QByteArray comment) |
Set the comment of this cookie. | |
void | setDomain (const QByteArray domain) |
Set the domain of this cookie. | |
void | setMaxAge (const int maxAge) |
Set the maximum age of this cookie in seconds. More... | |
void | setPath (const QByteArray path) |
Set the path for that the cookie will be sent, default="/" which means the whole domain. | |
void | setSecure (const bool secure) |
Set secure mode, so that the cookie will be sent by the browser to the server only on secure connections. | |
void | setHttpOnly (const bool httpOnly) |
Set HTTP-only mode, so that the browser does not allow client-side scripts to access the cookie. | |
void | setSameSite (const QByteArray sameSite) |
Set same-site mode, so that the browser does not allow other web sites to access the cookie. More... | |
QByteArray | getName () const |
Get the name of this cookie. | |
QByteArray | getValue () const |
Get the value of this cookie. | |
QByteArray | getComment () const |
Get the comment of this cookie. | |
QByteArray | getDomain () const |
Get the domain of this cookie. | |
int | getMaxAge () const |
Get the maximum age of this cookie in seconds. | |
QByteArray | getPath () const |
Set the path of this cookie. | |
bool | getSecure () const |
Get the secure flag of this cookie. | |
bool | getHttpOnly () const |
Get the HTTP-only flag of this cookie. | |
QByteArray | getSameSite () const |
Get the same-site flag of this cookie. | |
int | getVersion () const |
Returns always 1. | |
Static Public Member Functions | |
static QList< QByteArray > | splitCSV (const QByteArray source) |
Split a string list into parts, where each part is delimited by semicolon. More... | |
HTTP cookie as defined in RFC 2109.
Supports some additional attributes of RFC6265bis.
Definition at line 20 of file httpcookie.h.
HttpCookie::HttpCookie | ( | const QByteArray | name, |
const QByteArray | value, | ||
const int | maxAge, | ||
const QByteArray | path = "/" , |
||
const QByteArray | comment = QByteArray() , |
||
const QByteArray | domain = QByteArray() , |
||
const bool | secure = false , |
||
const bool | httpOnly = false , |
||
const QByteArray | sameSite = QByteArray() |
||
) |
Create a cookie and set name/value pair.
name | name of the cookie |
value | value of the cookie |
maxAge | maximum age of the cookie in seconds. 0=discard immediately |
path | Path for that the cookie will be sent, default="/" which means the whole domain |
comment | Optional comment, may be displayed by the web browser somewhere |
domain | Optional domain for that the cookie will be sent. Defaults to the current domain |
secure | If true, the cookie will be sent by the browser to the server only on secure connections |
httpOnly | If true, the browser does not allow client-side scripts to access the cookie |
sameSite | Declare if the cookie can only be read by the same site, which is a stronger restriction than the domain. Allowed values: "Lax" and "Strict". |
Definition at line 17 of file httpcookie.cpp.
HttpCookie::HttpCookie | ( | const QByteArray | source | ) |
Create a cookie from a string.
source | String as received in a HTTP Cookie2 header. |
Definition at line 33 of file httpcookie.cpp.
void HttpCookie::setMaxAge | ( | const int | maxAge | ) |
Set the maximum age of this cookie in seconds.
0=discard immediately
Definition at line 165 of file httpcookie.cpp.
void HttpCookie::setSameSite | ( | const QByteArray | sameSite | ) |
Set same-site mode, so that the browser does not allow other web sites to access the cookie.
Allowed values: "Lax" and "Strict".
Definition at line 185 of file httpcookie.cpp.
|
static |
Split a string list into parts, where each part is delimited by semicolon.
Semicolons within double quotes are skipped. Double quotes are removed.
Definition at line 240 of file httpcookie.cpp.