Share session cookie between Phoenix and Rails

Wondering how easy it is to share the cookie based session between Rails and Phoenix. Thinking about writing a portion of the site with Phoenix, but want to use the same cookie.

Right now we have multiple rails apps that have the same cookie secret token and session is shared. Works pretty well.

Digging through the source, it looks like they use very similar signing/encryption strategies BUT very different encodings by default.

  • the Phoenix session plumbing defaults to Erlang’s external term format here.

  • the Rails session plumbing now defaults to JSON, but used to default to Ruby’s Marshal format. here

The most interoperable choice is likely JSON; you can change the format in the Plug.Session config in your Phoenix app’s endpoint.ex.

The signing/encryption parts seem similar, but fixing the serialization (above) + trying it will take a lot less time than spelunking encryption code.


Thanks! I will try to mess around with the session format and encryption.