|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/manual/mod/mod_python/ |
Upload File : |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="modpython.css" type='text/css'>
<link rel="first" href="modpython.html" title='Mod_python Manual'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='index' href='genindex.html' title='Index'>
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="next" href="pyapi-cookie-example.html">
<LINK REL="prev" href="pyapi-cookie-classes.html">
<LINK REL="parent" href="pyapi-cookie.html">
<LINK REL="next" href="pyapi-cookie-example.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="Functions">
<META NAME="keywords" CONTENT="modpython">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>4.7.2 Functions</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="4.7.1 Classes"
href="pyapi-cookie-classes.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="4.7 Cookie - HTTP"
href="pyapi-cookie.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="4.7.3 Examples"
href="pyapi-cookie-example.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">Mod_python Manual</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
<td><a rel="index" title="Index"
href="genindex.html"><img src='index.gif'
border='0' height='32' alt='Index' width='32'></A></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="pyapi-cookie-classes.html">4.7.1 Classes</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="pyapi-cookie.html">4.7 Cookie - HTTP</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="pyapi-cookie-example.html">4.7.3 Examples</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION006720000000000000000"> </A>
<BR>
4.7.2 Functions
</H2>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-205"><tt class="function">add_cookie</tt></a></b>(</nobr></td>
<td><var>req, cookie</var><big>[</big><var>, value, attributes</var><big>]</big>)</td></tr></table>
<dd>
This is a convenience function for setting a cookie in request
headers. <var>req</var> is a mod_python <tt class="class">Request</tt> object. If
<var>cookie</var> is an instance of <tt class="class">Cookie</tt> (or subclass thereof),
then the cookie is set, otherwise, <var>cookie</var> must be a string, in
which case a <tt class="class">Cookie</tt> is constructed using <var>cookie</var> as
name, <var>value</var> as the value, along with any valid <tt class="class">Cookie</tt>
attributes specified as keyword arguments.
<P>
This function will also set "<tt class="samp">Cache-Control:
no-cache="set-cookie"</tt>" header to inform caches that the cookie value
should not be cached.
<P>
Here is one way to use this function:
<div class="verbatim"><pre>
c = Cookie.Cookie('spam', 'eggs', expires=time.time()+300)
Cookie.add_cookie(req, c)
</pre></div>
Here is another:
<div class="verbatim"><pre>
Cookie.add_cookie(req, 'spam', 'eggs', expires=time.time()+300)
</pre></div>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-206"><tt class="function">get_cookies</tt></a></b>(</nobr></td>
<td><var>req </var><big>[</big><var>, Class, data</var><big>]</big>)</td></tr></table>
<dd>
This is a convenience function for retrieving cookies from incoming
headers. <var>req</var> is a mod_python <tt class="class">Request</tt>
object. <var>Class</var> is a class whose <tt class="method">parse()</tt> method will be
used to parse the cookies, it defaults to <code>Cookie</code>. <var>Data</var>
can be any number of keyword arguments which, will be passed to
<tt class="method">parse()</tt> (This is useful for <tt class="class">signedCookie</tt> and
<tt class="class">MarshalCookie</tt> which require <code>secret</code> as an additional
argument to <tt class="method">parse</tt>).
</dl>
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="4.7.1 Classes"
rel="prev" title="4.7.1 Classes"
href="pyapi-cookie-classes.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="4.7 Cookie - HTTP"
rel="parent" title="4.7 Cookie - HTTP"
href="pyapi-cookie.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="4.7.3 Examples"
rel="next" title="4.7.3 Examples"
href="pyapi-cookie-example.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">Mod_python Manual</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
<td><a rel="index" title="Index"
rel="index" title="Index"
href="genindex.html"><img src='index.gif'
border='0' height='32' alt='Index' width='32'></A></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="pyapi-cookie-classes.html">4.7.1 Classes</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="pyapi-cookie.html">4.7 Cookie - HTTP</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="pyapi-cookie-example.html">4.7.3 Examples</A>
<hr>
<span class="release-info">Release 3.2.8, documentation updated on February 19, 2006.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>