<br><br><div class="gmail_quote">On Sat, May 17, 2008 at 3:10 PM, Bluebie, Jenna &lt;<a href="mailto:blueberry@creativepony.com">blueberry@creativepony.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Maybe it&#39;s best to stick with simple cookie support. If people really need much more I don&#39;t feel it unfair for them to need to hack it in themselves or move up to rails and the likes.<br>
</blockquote><div><br>Move to Rails?&nbsp; Now that&#39;s just crazy talk.&nbsp; :P<br><br>Anyone who wants &quot;complete&quot; cookie support can add a little bit of code to their Camping app that looks like this:<br><br><div style="margin-left: 40px;">
<font size="1"><span style="font-family: courier new,monospace;">module Learning::CookieWrapper</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp; def service(*a)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; @cgi_cookies&nbsp;&nbsp;&nbsp; = Camping::H.new</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; @default_cookie = Camping::H.new.merge({ :path =&gt; &#39;/&#39; })</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; response = super(*a)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; @cgi_cookies.each do |name, settings|</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c = @default_cookie.merge(settings);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://c.name">c.name</a> = name</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cookie = CGI::Cookie.new(c);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; headers[&#39;Set-Cookie&#39;].push(cookie.to_s)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; end</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; response</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp; end</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">end</span></font><br></div></div></div><br>Then, in your controllers, you can add hashes to @cgi_cookie that will be used to instantiate CGI::Cookie objects.&nbsp; <br>
<br><b>Example Code:</b><br><br><a href="http://github.com/beppu/learning/commit/c6559d42adaf8624d836ecb8b4f6bfaf53255e47">http://github.com/beppu/learning/commit/c6559d42adaf8624d836ecb8b4f6bfaf53255e47</a><br><br><a href="http://github.com/beppu/learning/tree/master/learning.rb">http://github.com/beppu/learning/tree/master/learning.rb</a>&nbsp; (lines 35-48, 51)<br>
<br><a href="http://github.com/beppu/learning/tree/master/learning/controllers.rb">http://github.com/beppu/learning/tree/master/learning/controllers.rb</a>&nbsp; (lines 142-150)<br><br><b>Live Demo:</b><br><br><a href="http://learning.kicks-ass.org/">http://learning.kicks-ass.org/</a><br>
<br><div style="margin-left: 40px;"><font face="georgia,serif">Submit a few bits of wisdom, and then go to:<br><br></font><div style="margin-left: 40px;"><a href="http://learning.kicks-ass.org/env">http://learning.kicks-ass.org/env</a><br>
<br><div style="margin-left: 40px;"><font face="georgia,serif">Look at HTTP_COOKIE to verify that Camping can indeed have &quot;complete&quot; cookie support w/ just a little bit of extra code.<br><br>Alternatively, if you have the Web Developer Toolbar for Firefox, you can look at [Cookies | View Cookie Information].<br>
<br></font></div></div></div><font face="arial,sans-serif">--beppu<br><br></font>