Class: N::Session
Overview
A web application session.
State is a neccessary evil but session variables should be avoided as much as possible. Session state is typically distributed to many servers so avoid storing complete objects in session variables, only store oids and small integer/strings.
The session should be persistable to survive server shutdowns.
Constant Summary collapse
- @@manager =
{}
Instance Attribute Summary collapse
-
#session_id ⇒ Object
readonly
The unique id of this session.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(context = nil) ⇒ Session
constructor
Create the session for the given context.
Constructor Details
#initialize(context = nil) ⇒ Session
Create the session for the given context.
59 60 61 |
# File 'lib/nitro/session.rb', line 59 def initialize(context = nil) @session_id = create_id end |
Instance Attribute Details
#session_id ⇒ Object (readonly)
The unique id of this session.
41 42 43 |
# File 'lib/nitro/session.rb', line 41 def session_id @session_id end |
Class Method Details
.lookup(context) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/nitro/session.rb', line 43 def self.lookup(context) if = context.[Session.] session = context.sessions[] end unless session session = Session.new(context) context.(Cookie.new(Session., session.session_id)) context.sessions[session.session_id] = session end return session end |