On Sat, May 17, 2008 at 3:10 PM, Bluebie, Jenna <[EMAIL PROTECTED]>
wrote:

>
> Maybe it's best to stick with simple cookie support. If people really need
> much more I don't feel it unfair for them to need to hack it in themselves
> or move up to rails and the likes.
>

Move to Rails?  Now that's just crazy talk.  :P

Anyone who wants "complete" cookie support can add a little bit of code to
their Camping app that looks like this:

module Learning::CookieWrapper
  def service(*a)
    @cgi_cookies    = Camping::H.new
    @default_cookie = Camping::H.new.merge({ :path => '/' })
    response = super(*a)
    @cgi_cookies.each do |name, settings|
      c = @default_cookie.merge(settings);
      c.name = name
      cookie = CGI::Cookie.new(c);
      headers['Set-Cookie'].push(cookie.to_s)
    end
    response
  end
end

Then, in your controllers, you can add hashes to @cgi_cookie that will be
used to instantiate CGI::Cookie objects.

*Example Code:*

http://github.com/beppu/learning/commit/c6559d42adaf8624d836ecb8b4f6bfaf53255e47

http://github.com/beppu/learning/tree/master/learning.rb  (lines 35-48, 51)

http://github.com/beppu/learning/tree/master/learning/controllers.rb  (lines
142-150)

*Live Demo:*

http://learning.kicks-ass.org/

Submit a few bits of wisdom, and then go to:

http://learning.kicks-ass.org/env

Look at HTTP_COOKIE to verify that Camping can indeed have "complete" cookie
support w/ just a little bit of extra code.

Alternatively, if you have the Web Developer Toolbar for Firefox, you can
look at [Cookies | View Cookie Information].

--beppu
_______________________________________________
Camping-list mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/camping-list

Reply via email to