轨之间共享饼干3和Rails 4.1 [英] sharing cookies between rails 3 and rails 4.1

查看:136
本文介绍了轨之间共享饼干3和Rails 4.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有共同的Rails 3之间饼干和Rails 4.1的应用程序。问题是,Rails 3的饼干都只是采用base64 EN codeD,但Rails的4.1饼干是加密的。

I am trying to have shared cookies between Rails 3 and Rails 4.1 apps. The problem is that the Rails 3 cookies are just base64 encoded, but the Rails 4.1 cookies are encrypted.

有没有什么办法来使双方的Rails 3和Rails 4.1 make来使用兼容的饼干?

Is there any way to make both Rails 3 and Rails 4.1 make to use compatible cookies?

有关现在最简单的方法似乎降级到Rails的4.0

For now the most easy way seems to downgrade to Rails 4.0

推荐答案

要得到这个工作未设置 secret_key_base ,而使用相同的 secret_token ,你在你的Rails应用程序3使用。然后,关键是要还设置 action_dispatch.cookies_serializer =:元帅。否则,轨道4存储该cookie的格式的Rails 3无法读取。

To get this working unset secret_key_base and instead use the same secret_token that you use in your Rails 3 app. Then the trick is to also set action_dispatch.cookies_serializer = :marshal. Otherwise Rails 4 stored the cookie in a format Rails 3 cannot read.

所以,我最后设置/初始化/ session_store.rb有

So my final config/initializers/session_store.rb has

Rails.application.config.action_dispatch.cookies_serializer = :marshal
Rails.application.config.secret_token = 'verylongstring'

这篇关于轨之间共享饼干3和Rails 4.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆