Namespace
Methods
C
N
Included Modules
Constants
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 }
 
Class Public methods
new(app, options = {})
# File actionpack/lib/action_controller/session/abstract_store.rb, line 150
def initialize(app, options = {})
  # Process legacy CGI options
  options = options.symbolize_keys
  if options.has_key?(:session_path)
    ActiveSupport::Deprecation.warn "Giving :session_path to SessionStore is deprecated, " <<
      "please use :path instead", caller
    options[:path] = options.delete(:session_path)
  end
  if options.has_key?(:session_key)
    ActiveSupport::Deprecation.warn "Giving :session_key to SessionStore is deprecated, " <<
      "please use :key instead", caller
    options[:key] = options.delete(:session_key)
  end
  if options.has_key?(:session_http_only)
    ActiveSupport::Deprecation.warn "Giving :session_http_only to SessionStore is deprecated, " <<
      "please use :httponly instead", caller
    options[:httponly] = options.delete(:session_http_only)
  end
  @app = app
  @default_options = DEFAULT_OPTIONS.merge(options)
  @key = @default_options[:key]
  @cookie_only = @default_options[:cookie_only]
end
Instance Public methods
call(env)
# File actionpack/lib/action_controller/session/abstract_store.rb, line 175
def call(env)
  prepare!(env)
  response = @app.call(env)
  session_data = env[ENV_SESSION_KEY]
  options = env[ENV_SESSION_OPTIONS_KEY]
  if !session_data.is_a?(AbstractStore::SessionHash) || session_data.loaded? || options[:expire_after]
    request = ActionController::Request.new(env)
    return response if (options[:secure] && !request.ssl?)
    session_data.send(:load!) if session_data.is_a?(AbstractStore::SessionHash) && !session_data.loaded?
    sid = options[:id] || generate_sid
    unless set_session(env, sid, session_data.to_hash)
      return response
    end
    request_cookies = env["rack.request.cookie_hash"]
    if (request_cookies.nil? || request_cookies[@key] != sid) || options[:expire_after]
      cookie = {:value => sid}
      cookie[:expires] = Time.now + options[:expire_after] if options[:expire_after]
      Rack::Utils.set_cookie_header!(response[1], @key, cookie.merge(options))
    end
  end
  response
end