public
Description: Everything I know about X, I learned from Y. (a simple Camping app)
Homepage: http://learning.kicks-ass.org/
Clone URL: git://github.com/beppu/learning.git
Click here to lend your support to: learning and make a donation at www.pledgie.com !
Learning::CookieWrapper + Examples
John Beppu (author)
Sun May 18 04:30:40 -0700 2008
commit  c6559d42adaf8624d836ecb8b4f6bfaf53255e47
tree    c3e4bc0fd8c6e5ee1ab4582a03fdc8f5e4ecddc2
parent  0785a11000c0e6be414b7205a9b9303114f5cbba
...
29
30
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
33
34
35
36
37
 
38
39
40
...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
51
52
53
54
0
@@ -29,12 +29,26 @@ module Learning::RequestWrapper
0
     @google_ad_slot = Learning::GOOGLE_AD_SLOT
0
     @google_analytics = Learning::GOOGLE_ANALYTICS
0
     response = super(*a)
0
+ end
0
+end
0
+
0
+module Learning::CookieWrapper
0
+ def service(*a)
0
+ @cgi_cookies = Camping::H.new
0
+ @default_cookie = Camping::H.new.merge({ :path => '/' })
0
+ response = super(*a)
0
+ @cgi_cookies.each do |name, settings|
0
+ c = @default_cookie.merge(settings);
0
+ c.name = name
0
+ cookie = CGI::Cookie.new(c);
0
+ headers['Set-Cookie'].push(cookie.to_s)
0
+ end
0
     response
0
   end
0
 end
0
 
0
 module Learning
0
- include Camping::Session, Learning::RequestWrapper
0
+ include Camping::Session, Learning::RequestWrapper, Learning::CookieWrapper
0
 
0
   def self.create
0
     Camping::Models::Session.create_schema
...
139
140
141
 
 
 
 
 
 
 
 
 
142
143
144
...
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
0
@@ -139,6 +139,15 @@ module Learning::Controllers
0
           pair.save
0
         end
0
       end
0
+ @cgi_cookies[topic.word] = {
0
+ :value => topic.word,
0
+ :secure => true
0
+ }
0
+ @cgi_cookies[teacher.word] = {
0
+ :value => teacher.word,
0
+ :secure => false,
0
+ :expires => Time.now + 4.years
0
+ }
0
       redirect R(Home)
0
     end
0
   end

Comments

    No one has commented yet.