sharing cookies between rails 3 and rails 4.1

前端 未结 2 543
礼貌的吻别
礼貌的吻别 2021-01-14 11:03

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 encrypt

2条回答
  •  情书的邮戳
    2021-01-14 11:16

    Have you tried unsetting secret_key_base and setting secret_token to the same value you're using in your Rails 3 app? This might not work, but I don't see anything in the 4.1 upgrade guide to suggest it wouldn't.

    If that doesn't work, the options I can think of:

    1. Switch to a different session store (Memcached, ActiveRecord, whatever). Not ideal, since it means more infrastructure, but it should work.
    2. Write your own cookie middleware. If you really need to share cookie information between multiple applications, this is your best long term solution. Don't depend on the pre-built Rails stuff, since (as you've found) that's hard to keep in sync. Write your own Rack middleware that's portable and does exactly what you need.

提交回复
热议问题