Module ActionController::SessionManagement::ClassMethods
In: vendor/rails/actionpack/lib/action_controller/session_management.rb

Methods

Public Instance methods

Specify how sessions ought to be managed for a subset of the actions on the controller. Like filters, you can specify :only and :except clauses to restrict the subset, otherwise options apply to all actions on this controller.

The session options are inheritable, as well, so if you specify them in a parent controller, they apply to controllers that extend the parent.

Usage:

  # turn off session management for all actions.
  session :off

  # turn off session management for all actions _except_ foo and bar.
  session :off, :except => %w(foo bar)

  # turn off session management for only the foo and bar actions.
  session :off, :only => %w(foo bar)

  # the session will only work over HTTPS, but only for the foo action
  session :only => :foo, :session_secure => true

  # the session will only be disabled for 'foo', and only if it is
  # requested as a web service
  session :off, :only => :foo,
          :if => Proc.new { |req| req.parameters[:ws] }

All session options described for ActionController::Base.process_cgi are valid arguments.

[Source]

    # File vendor/rails/actionpack/lib/action_controller/session_management.rb, line 66
66:       def session(*args)
67:         options = Hash === args.last ? args.pop : {}
68: 
69:         options[:disabled] = true if !args.empty?
70:         options[:only] = [*options[:only]].map { |o| o.to_s } if options[:only]
71:         options[:except] = [*options[:except]].map { |o| o.to_s } if options[:except]
72:         if options[:only] && options[:except]
73:           raise ArgumentError, "only one of either :only or :except are allowed"
74:         end
75: 
76:         write_inheritable_array("session_options", [options])
77:       end

Returns the hash used to configure the session. Example use:

  ActionController::Base.session_options[:session_secure] = true # session only available over HTTPS

[Source]

    # File vendor/rails/actionpack/lib/action_controller/session_management.rb, line 33
33:       def session_options
34:         ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS
35:       end

Returns the session store class currently used.

[Source]

    # File vendor/rails/actionpack/lib/action_controller/session_management.rb, line 26
26:       def session_store
27:         ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:database_manager]
28:       end

Set the session store to be used for keeping the session data between requests. The default is using the file system, but you can also specify one of the other included stores (:active_record_store, :drb_store, :mem_cache_store, or :memory_store) or use your own class.

[Source]

    # File vendor/rails/actionpack/lib/action_controller/session_management.rb, line 20
20:       def session_store=(store)
21:         ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:database_manager] =
22:           store.is_a?(Symbol) ? CGI::Session.const_get(store == :drb_store ? "DRbStore" : store.to_s.camelize) : store
23:       end

[Validate]