Changing host subdomain and persist conn / session

I created a Multi Tenant app with allowed “subdomains”.
Each tenant has a subdomain (ex:, and I can log in with “parent” user account.
When I change from to a new conn / session is started, and I have to log in again.
Is possible to mantain/persist conn / session (maybe with changed after this action?

PS: Elixir 1.5, Phoenix 1.3.


I think %Plug.Conn{} is created anew for each request, so there might not be much reason to persist it.

In order to persist a session, you probably need to add a cookie header like

Set-Cookie: name=value; domain=app.local

I would guess that’s what :domain option in Plug.Session is for, but I might be wrong.

See for more.


Thanks. It worked!
I edited endpoint.ex and my auth plug.


  plug Plug.Session,
    domain: ".app.local",

Hi, I am wondering what you did to your auth plug?