In Elixir, Phoenix, how to get session in other module as a module use Phoenix.Channel?

只谈情不闲聊 提交于 2021-02-04 18:39:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!