Rename session cookies in Rails

自闭症网瘾萝莉.ら 提交于 2020-05-29 02:30:17

问题


since I'd like the session cookie to reflect the url and not the app name, I'd like to rename the cookies..

The current session cookie name is called _APPNAME_session

is there a way to rename it to _somethingelse_session?

I see the name of it when I do

curl -i <appurl>

I see

set_cookie = _APPNAME_session=....

回答1:


In config/initializers/session_store.rb, set/change the following line:

  • For Rails < 5.0.0:

    <APPNAME>::Application.config.session_store :cookie_store, key: '_somethingelse_session'
    
  • For Rails >= 5.0.0:

    Rails.application.config.session_store :cookie_store, key: '_somethingelse_session'
    

And restart your application/server.



来源:https://stackoverflow.com/questions/13670420/rename-session-cookies-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!