Mash
Implicit assignment of cookie key and value.
name<~to_s> | Name of the cookie. |
value<~to_s> | Value of the cookie. |
By using this method, a cookie key is marked for being included in the Set-Cookie response header.
:api: public
# File lib/merb-core/dispatch/cookies.rb, line 23 23: def []=(key, value) 24: @_options_lookup[key] ||= {} 25: super 26: end
Removes the cookie on the client machine by setting the value to an empty string and setting its expiration date into the past.
name<~to_s> | Name of the cookie to delete. |
options | Additional options to pass to set_cookie. |
:api: public
# File lib/merb-core/dispatch/cookies.rb, line 60 60: def delete(name, options = {}) 61: set_cookie(name, "", options.merge("expires" => Time.at(0))) 62: end
Generate any necessary headers.
Hash | The headers to set, or an empty array if no cookies are set. |
:api: private
# File lib/merb-core/dispatch/cookies.rb, line 70 70: def extract_headers(controller_defaults = {}) 71: defaults = @_cookie_defaults.merge(controller_defaults) 72: cookies = [] 73: self.each do |name, value| 74: # Only set cookies that marked for inclusion in the response header. 75: next unless @_options_lookup[name] 76: options = defaults.merge(@_options_lookup[name]) 77: if (expiry = options["expires"]).respond_to?(:gmtime) 78: options["expires"] = expiry.gmtime.strftime(Merb::Const::COOKIE_EXPIRATION_FORMAT) 79: end 80: secure = options.delete("secure") 81: http_only = options.delete("http_only") 82: kookie = "#{name}=#{Merb::Parse.escape(value)}; " 83: # WebKit in particular doens't like empty cookie options - skip them. 84: options.each { |k, v| kookie << "#{k}=#{v}; " unless v.blank? } 85: kookie << 'secure; ' if secure 86: kookie << 'HttpOnly; ' if http_only 87: cookies << kookie.rstrip 88: end 89: cookies.empty? ? {} : { 'Set-Cookie' => cookies.join(Merb::Const::NEWLINE) } 90: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.