doc/api/classes/ActionController/Cookies.html
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module: ActionController::Cookies</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
<td class="class-name-in-header">ActionController::Cookies</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/vendor/rails/actionpack/lib/action_controller/cookies_rb.html">
vendor/rails/actionpack/lib/action_controller/cookies.rb
</a>
<br />
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Cookies.html">Cookies</a> are read and written through
ActionController#cookies. The <a href="Cookies.html#M000175">cookies</a>
being read are what were received along with the request, the <a
href="Cookies.html#M000175">cookies</a> being written are what will be sent
out with the response. <a href="Cookies.html">Cookies</a> are read by value
(so you won‘t get the <a href="Cookies.html#M000176">cookie</a>
object itself back — just the value it holds). Examples for writing:
</p>
<pre>
cookies[:user_name] = "david" # => Will set a simple session cookie
cookies[:login] = { :value => "XJ-122", :expires => 1.hour.from_now }
# => Will set a cookie that expires in 1 hour
</pre>
<p>
Examples for reading:
</p>
<pre>
cookies[:user_name] # => "david"
cookies.size # => 2
</pre>
<p>
Example for deleting:
</p>
<pre>
cookies.delete :user_name
</pre>
<p>
All the option symbols for setting <a
href="Cookies.html#M000175">cookies</a> are:
</p>
<ul>
<li><tt>value</tt> - the <a href="Cookies.html#M000176">cookie</a>‘s
value or list of values (as an array).
</li>
<li><tt>path</tt> - the path for which this <a
href="Cookies.html#M000176">cookie</a> applies. Defaults to the root of the
application.
</li>
<li><tt>domain</tt> - the domain for which this <a
href="Cookies.html#M000176">cookie</a> applies.
</li>
<li><tt>expires</tt> - the time at which this <a
href="Cookies.html#M000176">cookie</a> expires, as a <tt>Time</tt> object.
</li>
<li><tt>secure</tt> - whether this <a href="Cookies.html#M000176">cookie</a> is
a secure <a href="Cookies.html#M000176">cookie</a> or not (default to
false). Secure <a href="Cookies.html#M000175">cookies</a> are only
transmitted to HTTPS servers.
</li>
</ul>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000176">cookie</a>
<a href="#M000175">cookies</a>
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Protected Instance methods</h3>
<div id="method-M000176" class="method-detail">
<a name="M000176"></a>
<div class="method-heading">
<a href="#M000176" class="method-signature">
<span class="method-name">cookie</span><span class="method-args">(*options)</span>
</a>
</div>
<div class="method-description">
<p>
Deprecated <a href="Cookies.html#M000176">cookie</a> writer method
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000176-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000176-source">
<pre>
<span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_controller/cookies.rb, line 35</span>
35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cookie</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">options</span>)
36: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">headers</span>[<span class="ruby-value str">'cookie'</span>] <span class="ruby-operator"><<</span> <span class="ruby-constant">CGI</span><span class="ruby-operator">::</span><span class="ruby-constant">Cookie</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">options</span>)
37: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000175" class="method-detail">
<a name="M000175"></a>
<div class="method-heading">
<a href="#M000175" class="method-signature">
<span class="method-name">cookies</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
Returns the <a href="Cookies.html#M000176">cookie</a> container, which
operates as described above.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000175-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000175-source">
<pre>
<span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_controller/cookies.rb, line 30</span>
30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cookies</span>
31: <span class="ruby-constant">CookieJar</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
32: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>