Zed*_*TuX 6 cookies ruby-on-rails
我正在将 Rails 4.2 应用程序迁移到 Rails 5.2。
在代码中,我们设置一个cookie:
cookies.permanent.signed["wsid#{session[:user_id]}".to_sym] = { value: wsid, httponly: true }
Run Code Online (Sandbox Code Playgroud)
然后用以下命令取回它:
cookies.permanent.signed["wsid#{session[:user_id]}".to_sym]
Run Code Online (Sandbox Code Playgroud)
升级 Rails 后,该值不再可读。
在仔细检查升级 Ruby on Rails 指南后,我发现从 Rails 5.1 迁移到 5.2,cookie 发生了变化。
所以我将以下内容添加到所有环境文件中:
# controls whether signed and encrypted cookies use the AES-256-GCM cipher or
# the older AES-256-CBC cipher. It defaults to true.
config.action_dispatch.use_authenticated_cookie_encryption = false
Run Code Online (Sandbox Code Playgroud)
但我仍然无法访问这些值。
有人可以帮我解决这个问题吗?
我读到了有关的内容,secret_key_base我明白这cookies是在幕后加密数据,但实际上上面代码定义的值似乎没有加密,因为使用Base64.decode64我可以看到正确的值。
| 归档时间: |
|
| 查看次数: |
545 次 |
| 最近记录: |