Table of Contents
- QNetworkCookieJar
- Synopsis
- Detailed Description
PySide2.QtNetwork.QNetworkCookieJar
PySide2.QtNetwork.QNetworkCookieJar.allCookies()
PySide2.QtNetwork.QNetworkCookieJar.cookiesForUrl()
PySide2.QtNetwork.QNetworkCookieJar.deleteCookie()
PySide2.QtNetwork.QNetworkCookieJar.insertCookie()
PySide2.QtNetwork.QNetworkCookieJar.setAllCookies()
PySide2.QtNetwork.QNetworkCookieJar.setCookiesFromUrl()
PySide2.QtNetwork.QNetworkCookieJar.updateCookie()
PySide2.QtNetwork.QNetworkCookieJar.validateCookie()
Previous topic
Next topic
Quick search
QNetworkCookieJar¶
The
QNetworkCookieJar
class implements a simple jar ofQNetworkCookie
objects. More…
Synopsis¶
Functions¶
def
allCookies
()def
setAllCookies
(cookieList)
Virtual functions¶
def
cookiesForUrl
(url)def
deleteCookie
(cookie)def
insertCookie
(cookie)def
setCookiesFromUrl
(cookieList, url)def
updateCookie
(cookie)def
validateCookie
(cookie, url)
Detailed Description¶
Cookies are small bits of information that stateless protocols like HTTP use to maintain some persistent information across requests.
A cookie is set by a remote server when it replies to a request and it expects the same cookie to be sent back when further requests are sent.
The cookie jar is the object that holds all cookies set in previous requests. Web browsers save their cookie jars to disk in order to conserve permanent cookies across invocations of the application.
QNetworkCookieJar
does not implement permanent storage: it only keeps the cookies in memory. Once theQNetworkCookieJar
object is deleted, all cookies it held will be discarded as well. If you want to save the cookies, you should derive from this class and implement the saving to disk to your own storage format.This class implements only the basic security recommended by the cookie specifications and does not implement any cookie acceptance policy (it accepts all cookies set by any requests). In order to override those rules, you should reimplement the
cookiesForUrl()
andsetCookiesFromUrl()
virtual functions. They are called byQNetworkReply
andQNetworkAccessManager
when they detect new cookies and when they require cookies.
- class PySide2.QtNetwork.QNetworkCookieJar([parent=None])¶
- param parent:
Creates a
QNetworkCookieJar
object and sets the parent object to beparent
.The cookie jar is initialized to empty.
- PySide2.QtNetwork.QNetworkCookieJar.allCookies()¶
- Return type:
Returns all cookies stored in this cookie jar. This function is suitable for derived classes to save cookies to disk, as well as to implement cookie expiration and other policies.
See also
- PySide2.QtNetwork.QNetworkCookieJar.cookiesForUrl(url)¶
- Parameters:
url –
PySide2.QtCore.QUrl
- Return type:
Returns the cookies to be added to when a request is sent to
url
. This function is called by the defaultcreateRequest()
, which adds the cookies returned by this function to the request being sent.If more than one cookie with the same name is found, but with differing paths, the one with longer path is returned before the one with shorter path. In other words, this function returns cookies sorted decreasingly by path length.
The default
QNetworkCookieJar
class implements only a very basic security policy (it makes sure that the cookies’ domain and path match the reply’s). To enhance the security policy with your own algorithms, override .See also
- PySide2.QtNetwork.QNetworkCookieJar.deleteCookie(cookie)¶
- Parameters:
cookie –
PySide2.QtNetwork.QNetworkCookie
- Return type:
bool
Deletes from cookie jar the cookie found to have the same identifier as
cookie
.Returns
true
if a cookie was deleted, false otherwise.See also
- PySide2.QtNetwork.QNetworkCookieJar.insertCookie(cookie)¶
- Parameters:
cookie –
PySide2.QtNetwork.QNetworkCookie
- Return type:
bool
Adds
cookie
to this cookie jar.Returns
true
ifcookie
was added, false otherwise.If a cookie with the same identifier already exists in the cookie jar, it will be overridden.
- PySide2.QtNetwork.QNetworkCookieJar.setAllCookies(cookieList)¶
- Parameters:
cookieList –
Sets the internal list of cookies held by this cookie jar to be
cookieList
. This function is suitable for derived classes to implement loading cookies from permanent storage, or their own cookie acceptance policies by reimplementingsetCookiesFromUrl()
.See also
- PySide2.QtNetwork.QNetworkCookieJar.setCookiesFromUrl(cookieList, url)¶
- Parameters:
cookieList –
url –
PySide2.QtCore.QUrl
- Return type:
bool
Adds the cookies in the list
cookieList
to this cookie jar. Before being inserted cookies are normalized.Returns
true
if one or more cookies are set forurl
, otherwise false.If a cookie already exists in the cookie jar, it will be overridden by those in
cookieList
.The default
QNetworkCookieJar
class implements only a very basic security policy (it makes sure that the cookies’ domain and path match the reply’s). To enhance the security policy with your own algorithms, override .Also,
QNetworkCookieJar
does not have a maximum cookie jar size. Reimplement this function to discard older cookies to create room for new ones.See also
- PySide2.QtNetwork.QNetworkCookieJar.updateCookie(cookie)¶
- Parameters:
cookie –
PySide2.QtNetwork.QNetworkCookie
- Return type:
bool
If a cookie with the same identifier as
cookie
exists in this cookie jar it will be updated. This function usesinsertCookie()
.Returns
true
ifcookie
was updated, false if no cookie in the jar matches the identifier ofcookie
.See also
- PySide2.QtNetwork.QNetworkCookieJar.validateCookie(cookie, url)¶
- Parameters:
cookie –
PySide2.QtNetwork.QNetworkCookie
url –
PySide2.QtCore.QUrl
- Return type:
bool
Returns
true
if the domain and path ofcookie
are valid, false otherwise. Theurl
parameter is used to determine if the domain specified in the cookie is allowed.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.