Guest User

Untitled

a guest
Feb 19th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. # ==== Parameters
  2. # name<~to_s>:: Name of the cookie.
  3. # value<~to_s>:: Value of the cookie.
  4. # options<Hash>:: Additional options for the cookie (see below).
  5. #
  6. # ==== Options (options)
  7. # :path<String>:: The path for which this cookie applies. Defaults to "/".
  8. # :expires<Time>:: Cookie expiry date.
  9. def set_cookie(name, value, options)
  10. options[:path] = '/' unless options[:path]
  11. if expiry = options[:expires]
  12. options[:expires] = expiry.gmtime.strftime(Merb::Const::COOKIE_EXPIRATION_FORMAT)
  13. end
  14. # options are sorted for testing purposes
  15. (@_headers['Set-Cookie'] ||=[]) << "#{name}=#{value}; " +
  16. options.map{|k, v| "#{k}=#{v};"}.sort.join(' ')
  17. end
Add Comment
Please, Sign In to add comment