提交 5a1251dc 编写于 作者: J Jeremy Kemper

Session configuration in config/environment.rb instead of app/controllers/application.rb

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6198 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 45dd2568
...@@ -81,6 +81,9 @@ def session(*args) ...@@ -81,6 +81,9 @@ def session(*args)
write_inheritable_array("session_options", [options]) write_inheritable_array("session_options", [options])
end end
# So we can declare session options in the Rails initializer.
alias_method :session=, :session
def cached_session_options #:nodoc: def cached_session_options #:nodoc:
@session_options ||= read_inheritable_attribute("session_options") || [] @session_options ||= read_inheritable_attribute("session_options") || []
end end
......
...@@ -41,6 +41,10 @@ ...@@ -41,6 +41,10 @@
# Make Active Record use UTC-base instead of local time # Make Active Record use UTC-base instead of local time
# config.active_record.default_timezone = :utc # config.active_record.default_timezone = :utc
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
config.action_controller.session = { :secret => '<%= CGI::Session.generate_unique_id(app_name) %>' }
# See Rails::Configuration for more options # See Rails::Configuration for more options
end end
......
...@@ -2,9 +2,4 @@ ...@@ -2,9 +2,4 @@
# Likewise, all the methods added will be available for all controllers. # Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
# Pick a unique cookie name to distinguish our session from others.
# Session data is stored in a cookie by default, so the data is hashed
# with a secret to ensure its integrity.
session :session_key => '_<%= app_name %>_session',
:secret => '<%= CGI::Session.generate_unique_id(app_name) %>'
end end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册