Module: Roda::RodaPlugins::Cookies::ResponseMethods

Defined in:
lib/roda/plugins/cookies.rb

Instance Method Summary collapse

Instance Method Details

Modify the headers to include a Set-Cookie value that deletes the cookie. A value hash can be provided to override the default one used to delete the cookie. Example:

response.delete_cookie('foo')
response.delete_cookie('foo', domain: 'example.org')


34
35
36
# File 'lib/roda/plugins/cookies.rb', line 34

def delete_cookie(key, value = {})
  ::Rack::Utils.delete_cookie_header!(@headers, key, roda_class.opts[:cookies_opts].merge(value))
end

Set the cookie with the given key in the headers.

response.set_cookie('foo', 'bar')
response.set_cookie('foo', value: 'bar', domain: 'example.org')


42
43
44
45
# File 'lib/roda/plugins/cookies.rb', line 42

def set_cookie(key, value)
  value = { :value=>value } unless value.respond_to?(:keys)
  ::Rack::Utils.set_cookie_header!(@headers, key, roda_class.opts[:cookies_opts].merge(value))
end