@@ -1616,16 +1616,28 @@ \subsection{Classes\label{pyapi-cookie-classes}}
16161616
16171617\subsection {Functions\label {pyapi-cookie-func } }
16181618
1619- \begin {funcdesc }{setCookie }{req, cookie}
1619+ \begin {funcdesc }{addCookie }{req, cookie\optional {, value, attributes} }
16201620 This is a convenience function for setting a cookie in request
1621- headers. \var {req} is a mod_python \class {Request} object,
1622- \var {cookie} is an object whose string representation is a valid
1623- cookie. (Most often it is an instance of mod_python \class {Cookie}
1624- or any of its subclasses).
1621+ headers. \var {req} is a mod_python \class {Request} object. If
1622+ \var {cookie} is an instance of \class {Cookie} (or subclass thereof),
1623+ then the cookie is set, otherwise, \var {cookie} must be a string, in
1624+ which case a \class {Cookie} is constructed using \var {cookie} as
1625+ name, \var {value} as the value, along with any valid \class {Cookie}
1626+ attributes specified as keyword arguments.
16251627
16261628 This function will also set \samp {Cache-Control:
16271629 no-cache="set-cookie"} header to inform caches that the cookie value
16281630 should not be cached.
1631+
1632+ Here is one way to use this function:
1633+ \begin {verbatim }
1634+ c = Cookie.Cookie('spam', 'eggs', expires=time.time()+300)
1635+ Cookie.addCookie(req, c)
1636+ \end {verbatim }
1637+ Here is another:
1638+ \begin {verbatim }
1639+ Cookie.addCookie(req, 'spam', 'eggs', expires=time.time()+300)
1640+ \end {verbatim }
16291641\end {funcdesc }
16301642
16311643\begin {funcdesc }{getCookies}{req \optional {, Class, data}}
@@ -1651,7 +1663,7 @@ \subsection{Examples\label{pyapi-cookie-example}}
16511663
16521664 cookie = Cookie.Cookie('eggs', 'spam')
16531665 cookie.expires = time.time() + 300
1654- Cookie.setCookie (req, cookie)
1666+ Cookie.addCookie (req, cookie)
16551667
16561668 req.write('This response contains a cookie!\n')
16571669 return apache.OK
@@ -1685,7 +1697,7 @@ \subsection{Examples\label{pyapi-cookie-example}}
16851697
16861698 # MarshaCookie allows value to be any marshallable object
16871699 value = {'egg_count': 32, 'color': 'white'}
1688- Cookie.setCookie (req, Cookie.MarshalCookie('spam', value, \
1700+ Cookie.addCookie (req, Cookie.MarshalCookie('spam', value, \
16891701 'secret007'))
16901702 req.write('Spam cookie not found, but we just set one!\n')
16911703
0 commit comments