Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sharing cookies between rails 3 and 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.

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

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

like image 750
petr.sigut Avatar asked Mar 19 '23 03:03

petr.sigut


1 Answers

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.

So my final config/initializers/session_store.rb has

Rails.application.config.action_dispatch.cookies_serializer = :marshal
Rails.application.config.secret_token = 'verylongstring'
like image 182
Daniel Avatar answered Mar 24 '23 19:03

Daniel