lib/action_controller/cookies.rb in actionpack-1.13.6 vs lib/action_controller/cookies.rb in actionpack-2.0.0

- old
+ new

@@ -21,33 +21,34 @@ # * <tt>value</tt> - the cookie's value or list of values (as an array). # * <tt>path</tt> - the path for which this cookie applies. Defaults to the root of the application. # * <tt>domain</tt> - the domain for which this cookie applies. # * <tt>expires</tt> - the time at which this cookie expires, as a +Time+ object. # * <tt>secure</tt> - whether this cookie is a secure cookie or not (default to false). - # Secure cookies are only transmitted to HTTPS servers. + # Secure cookies are only transmitted to HTTPS servers. + # * <tt>http_only</tt> - whether this cookie is accessible via scripting or only HTTP (defaults to false). + module Cookies + def self.included(base) + base.helper_method :cookies + end + protected # Returns the cookie container, which operates as described above. def cookies CookieJar.new(self) end - - # Deprecated cookie writer method - def cookie(*options) - response.headers['cookie'] << CGI::Cookie.new(*options) - end end class CookieJar < Hash #:nodoc: def initialize(controller) @controller, @cookies = controller, controller.request.cookies super() update(@cookies) end - # Returns the value of the cookie by +name+ -- or nil if no such cookie exists. You set new cookies using either the cookie method - # or cookies[]= (for simple name/value cookies without options). + # Returns the value of the cookie by +name+ -- or nil if no such cookie exists. You set new cookies using cookies[]= + # (for simple name/value cookies without options). def [](name) cookie = @cookies[name.to_s] if cookie && cookie.respond_to?(:value) cookie.size > 1 ? cookie.value : cookie.value.to_s end @@ -78,6 +79,6 @@ cookie = CGI::Cookie.new(options) @controller.logger.info "Cookie set: #{cookie}" unless @controller.logger.nil? @controller.response.headers["cookie"] << cookie end end -end +end \ No newline at end of file