<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QNetworkCookieJar Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QNetworkCookieJar Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QNetworkCookieJar class implements a simple jar of <a href="qnetworkcookie.html">QNetworkCookie</a> objects <a href="#details">More...</a></p> <p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qnetworkcookiejar.html#QNetworkCookieJar">__init__</a></b> (<i>self</i>, QObject <i>parent</i> = None)</li><li><div class="fn" />list-of-QNetworkCookie <b><a href="qnetworkcookiejar.html#allCookies">allCookies</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QNetworkCookie <b><a href="qnetworkcookiejar.html#cookiesForUrl">cookiesForUrl</a></b> (<i>self</i>, QUrl <i>url</i>)</li><li><div class="fn" /><b><a href="qnetworkcookiejar.html#setAllCookies">setAllCookies</a></b> (<i>self</i>, list-of-QNetworkCookie <i>cookieList</i>)</li><li><div class="fn" />bool <b><a href="qnetworkcookiejar.html#setCookiesFromUrl">setCookiesFromUrl</a></b> (<i>self</i>, list-of-QNetworkCookie <i>cookieList</i>, QUrl <i>url</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QNetworkCookieJar class implements a simple jar of <a href="qnetworkcookie.html">QNetworkCookie</a> objects</p> <p>Cookies are small bits of information that stateless protocols like HTTP use to maintain some persistent information across requests.</p> <p>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.</p> <p>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.</p> <p>QNetworkCookieJar does not implement permanent storage: it only keeps the cookies in memory. Once the QNetworkCookieJar 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.</p> <p>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 <a href="qnetworkcookiejar.html#cookiesForUrl">cookiesForUrl</a>() and <a href="qnetworkcookiejar.html#setCookiesFromUrl">setCookiesFromUrl</a>() virtual functions. They are called by <a href="qnetworkreply.html">QNetworkReply</a> and <a href="qnetworkaccessmanager.html">QNetworkAccessManager</a> when they detect new cookies and when they require cookies.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QNetworkCookieJar" />QNetworkCookieJar.__init__ (<i>self</i>, <a href="qobject.html">QObject</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Creates a <a href="qnetworkcookiejar.html">QNetworkCookieJar</a> object and sets the parent object to be <i>parent</i>.</p> <p>The cookie jar is initialized to empty.</p> <h3 class="fn"><a name="allCookies" />list-of-QNetworkCookie QNetworkCookieJar.allCookies (<i>self</i>)</h3><p>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.</p> <p><b>See also</b> <a href="qnetworkcookiejar.html#setAllCookies">setAllCookies</a>() and <a href="qnetworkcookiejar.html#cookiesForUrl">cookiesForUrl</a>().</p> <h3 class="fn"><a name="cookiesForUrl" />list-of-QNetworkCookie QNetworkCookieJar.cookiesForUrl (<i>self</i>, <a href="qurl.html">QUrl</a> <i>url</i>)</h3><p>Returns the cookies to be added to when a request is sent to <i>url</i>. This function is called by the default <a href="qnetworkaccessmanager.html#createRequest">QNetworkAccessManager.createRequest</a>(), which adds the cookies returned by this function to the request being sent.</p> <p>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.</p> <p>The default <a href="qnetworkcookiejar.html">QNetworkCookieJar</a> 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 cookiesForUrl().</p> <p><b>See also</b> <a href="qnetworkcookiejar.html#setCookiesFromUrl">setCookiesFromUrl</a>() and <a href="qnetworkaccessmanager.html#setCookieJar">QNetworkAccessManager.setCookieJar</a>().</p> <h3 class="fn"><a name="setAllCookies" />QNetworkCookieJar.setAllCookies (<i>self</i>, list-of-QNetworkCookie <i>cookieList</i>)</h3><p>Sets the internal list of cookies held by this cookie jar to be <i>cookieList</i>. This function is suitable for derived classes to implement loading cookies from permanent storage, or their own cookie acceptance policies by reimplementing <a href="qnetworkcookiejar.html#setCookiesFromUrl">setCookiesFromUrl</a>().</p> <p><b>See also</b> <a href="qnetworkcookiejar.html#allCookies">allCookies</a>() and <a href="qnetworkcookiejar.html#setCookiesFromUrl">setCookiesFromUrl</a>().</p> <h3 class="fn"><a name="setCookiesFromUrl" />bool QNetworkCookieJar.setCookiesFromUrl (<i>self</i>, list-of-QNetworkCookie <i>cookieList</i>, <a href="qurl.html">QUrl</a> <i>url</i>)</h3><p>Adds the cookies in the list <i>cookieList</i> to this cookie jar. Default values for path and domain are taken from the <i>url</i> object.</p> <p>Returns true if one or more cookies are set for <i>url</i>, otherwise false.</p> <p>If a cookie already exists in the cookie jar, it will be overridden by those in <i>cookieList</i>.</p> <p>The default <a href="qnetworkcookiejar.html">QNetworkCookieJar</a> 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 setCookiesFromUrl().</p> <p>Also, <a href="qnetworkcookiejar.html">QNetworkCookieJar</a> does not have a maximum cookie jar size. Reimplement this function to discard older cookies to create room for new ones.</p> <p><b>See also</b> <a href="qnetworkcookiejar.html#cookiesForUrl">cookiesForUrl</a>() and <a href="qnetworkaccessmanager.html#setCookieJar">QNetworkAccessManager.setCookieJar</a>().</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>