| Class | Maveric::Sessions::Session |
| In: |
maveric/sessions.rb
|
| Parent: | Object |
Because apparently sessions are handy or helpful or something like that. Implemented as that the hex of their #object_id (the one you‘d see in an Object#inspect) is treated as a session id.
| DURATION | = | 15*60 |
| data | [R] | |
| duration | [R] | |
| expires | [R] |
The default session length is 15 minutes. Simple to change.
# File maveric/sessions.rb, line 25
25: def initialize duration=DURATION
26: ::Maveric.type_check :duration, duration, Integer
27: @duration, @data = duration, {}
28: touch
29: ::Maveric.log.debug self
30: end
One session is less than another if it expires sooner. Useful if we are managing in a manner akin to a priority stack.
# File maveric/sessions.rb, line 37
37: def <=> obj; Session === obj ? self.expires <=> obj.expires : super; end
Perhaps better named as #to_cookie for clarity?
# File maveric/sessions.rb, line 41
41: def to_s env=nil
42: touch
43: c = "#{::Maveric::Sessions::COOKIE_NAME}=#{id}" #required
44: c << "; expires=#{expires.httpdate}"
45: return c unless env
46: c << "; domain=#{env['SERVER_NAME']};"
47: # need to determine a good way to discern proper path.
48: # pertinant Maveric?
49: c << "; secure" if false
50: c
51: end