问题
In Elixir and Phoenix, I can get session in Controller by
Plug.Conn.get_session(conn, :id)
So how to get session in other module as a module use Phoenix.Channel
?
回答1:
Plug.Conn
is not available in Phoenix.Channel. Channels rely on Phoenix.Socket instead and you can use Phoenix.Token for authentication.
Here's a tutorial on how to authenticate channels in Phoenix.
来源:https://stackoverflow.com/questions/34446712/in-elixir-phoenix-how-to-get-session-in-other-module-as-a-module-use-phoenix-c