Create a new CGI::Cookie object.
The contents of the cookie can be specified as a name and one or more value arguments. Alternatively, the contents can be specified as a single hash argument. The possible keywords of this hash are as follows:
| name: | the name of the cookie. Required. |
| value: | the cookie’s value or list of values. |
| path: | the path for which this cookie applies. Defaults to the base directory of the CGI script. |
| domain: | the domain for which this cookie applies. |
| expires: | the time at which this cookie expires, as a Time object. |
| secure: | whether this cookie is a secure cookie or not (default to false). Secure cookies are only transmitted to HTTPS servers. |
| http_only: | whether this cookie can be accessed by client side scripts (e.g. document.cookie) or only over HTTP More details: msdn2.microsoft.com/en-us/library/system.web.httpc... Defaults to false. |
These keywords correspond to attributes of the cookie object.
Source Code
# File action_controller/cgi_ext/cookie.rb, line 29 def initialize(name = '', *value) if name.kind_of?(String) @name = name @value = Array(value) @domain = nil @expires = nil @secure = false @http_only = false @path = nil else @name = name['name'] @value = Array(name['value']) @domain = name['domain'] @expires = name['expires'] @secure = name['secure'] || false @http_only = name['http_only'] || false @path = name['path'] end raise ArgumentError, "`name' required" unless @name # simple support for IE unless @path %r|^(.*/)|.match(ENV['SCRIPT_NAME']) @path = ($1 or '') end super(@value) end
<code/>and<pre/>for code samples.