Class | Merb::Cookies |
In: |
lib/merb-core/dispatch/cookies.rb
|
Parent: | Object |
Cookies are read and written through Merb::Controller#cookies. The cookies you read are those received in request along with those that have been set during the current request. The cookies you write will be sent out with the response. Cookies are read by value (so you won‘t get the cookie object itself back — just the value it holds).
name<~to_s>: | Name of the cookie. |
options<Hash, ~to_s>: | Options for the cookie being set (see below). |
:value<~to_s>: | Value of the cookie |
:path<String>: | The path for which this cookie applies. Defaults to "/". |
:expires<Time>: | Cookie expiry date. |
If options is not a hash, it will be used as the cookie value directly.
cookies[:user] = "dave" # => Sets a simple session cookie cookies[:token] = { :value => user.token, :expires => Time.now + 2.weeks } # => Will set a cookie that expires in 2 weeks
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<Hash>: | Additional options to pass to set_cookie. |