重命名Rails中的会话Cookie
因为我希望会话cookie反映URL而不是应用程序名称,所以我想重命名cookie。
since I'd like the session cookie to reflect the url and not the app name, I'd like to rename the cookies..
当前会话cookie名称称为 _APPNAME_session
The current session cookie name is called _APPNAME_session
是否可以将其重命名为 _somethingelse_session
?
is there a way to rename it to _somethingelse_session
?
我看到的时候会看到它的名字
I see the name of it when I do
curl -i <appurl>
我看到
set_cookie = _APPNAME_session=....
-
Rails> = 6.0.0,在config / application.rb中,添加以下行:
-
Rails >= 6.0.0, in config/application.rb, add the following line:
config.session_store :cookie_store, key: '_somethingelse_session'
-
Rails > = 5.0.0,在config / initializers / session_store.rb中,设置/更改以下行:
-
Rails >= 5.0.0, in config/initializers/session_store.rb, set/change the following line:
Rails.application.config.session_store :cookie_store, key: '_somethingelse_session'
-
Rails< 5.0.0,在config / initializers / session_store.rb中,设置/更改以下行:
-
Rails < 5.0.0, in config/initializers/session_store.rb, set/change the following line:
<APPNAME>::Application.config.session_store :cookie_store, key: '_somethingelse_session'
-