new(name = "", *value)
public
Create a new CGI::Cookie object.
name_string |
The name of the cookie; in this form, there is no #domain or #expiration.
The #path is gleaned from the SCRIPT_NAME environment variable,
and #secure is false.
|
*value |
value or list of values of the cookie
|
options_hash |
A Hash of options to initialize this Cookie.
Possible options are:
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 the value of the SCRIPT_NAME
environment variable.
| 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.
| httponly |
whether this cookie is a HttpOnly cookie or not (default to
|
false). HttpOnly cookies are not available to javascript.
These keywords correspond to attributes of the cookie object.
|
Show source
def initialize(name = "", *value)
@domain = nil
@expires = nil
if name.kind_of?(String)
@name = name
%^(.*/)|.match(ENV["SCRIPT_NAME"])
@path = ($1 or "")
@secure = false
@httponly = false
return super(value)
end
options = name
unless options.has_key?("name")
raise ArgumentError, "`name' required"
end
@name = options["name"]
value = Array(options["value"])
# simple support for IE
if options["path"]
@path = options["path"]
else
%^(.*/)|.match(ENV["SCRIPT_NAME"])
@path = ($1 or "")
end
@domain = options["domain"]
@expires = options["expires"]
@secure = options["secure"] == true
@httponly = options["httponly"] == true
super(value)
end