Class: ActionController::Session::AbstractStore
- Includes:
- SessionUtils
- Defined in:
- lib/action_controller/session/abstract_store.rb
Defined Under Namespace
Modules: SessionUtils Classes: OptionsHash, SessionHash
Constant Summary collapse
- ENV_SESSION_KEY =
'rack.session'.freeze
- ENV_SESSION_OPTIONS_KEY =
'rack.session.options'.freeze
- HTTP_COOKIE =
'HTTP_COOKIE'.freeze
- SET_COOKIE =
'Set-Cookie'.freeze
- DEFAULT_OPTIONS =
{ :key => '_session_id', :path => '/', :domain => nil, :expire_after => nil, :secure => false, :httponly => true, :cookie_only => true }
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ AbstractStore
constructor
A new instance of AbstractStore.
Constructor Details
#initialize(app, options = {}) ⇒ AbstractStore
Returns a new instance of AbstractStore.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/action_controller/session/abstract_store.rb', line 150 def initialize(app, = {}) # Process legacy CGI options = .symbolize_keys if .has_key?(:session_path) ActiveSupport::Deprecation.warn "Giving :session_path to SessionStore is deprecated, " << "please use :path instead", caller [:path] = .delete(:session_path) end if .has_key?(:session_key) ActiveSupport::Deprecation.warn "Giving :session_key to SessionStore is deprecated, " << "please use :key instead", caller [:key] = .delete(:session_key) end if .has_key?(:session_http_only) ActiveSupport::Deprecation.warn "Giving :session_http_only to SessionStore is deprecated, " << "please use :httponly instead", caller [:httponly] = .delete(:session_http_only) end @app = app @default_options = DEFAULT_OPTIONS.merge() @key = @default_options[:key] @cookie_only = @default_options[:cookie_only] end |
Instance Method Details
#call(env) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/action_controller/session/abstract_store.rb', line 175 def call(env) prepare!(env) response = @app.call(env) session_data = env[ENV_SESSION_KEY] = env[ENV_SESSION_OPTIONS_KEY] if !session_data.is_a?(AbstractStore::SessionHash) || session_data.loaded? || [:expire_after] request = ActionController::Request.new(env) return response if ([:secure] && !request.ssl?) session_data.send(:load!) if session_data.is_a?(AbstractStore::SessionHash) && !session_data.loaded? sid = [:id] || generate_sid unless set_session(env, sid, session_data.to_hash) return response end = env["rack.request.cookie_hash"] if (.nil? || [@key] != sid) || [:expire_after] = {:value => sid} [:expires] = Time.now + [:expire_after] if [:expire_after] Rack::Utils.(response[1], @key, .merge()) end end response end |