在Phoenix的Elixir中,如何使用Phoenix.Channel在其他模块中获取会话? [英] In Elixir, Phoenix, how to get session in other module as a module use Phoenix.Channel?
本文介绍了在Phoenix的Elixir中,如何使用Phoenix.Channel在其他模块中获取会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Elixir和Phoenix中,我可以通过
In Elixir and Phoenix, I can get session in Controller by
Plug.Conn.get_session(conn, :id)
那么如何使用 Phoenix.Channel
在其他模块中获取会话?
So how to get session in other module as a module use Phoenix.Channel
?
推荐答案
Plug.Conn
在 Phoenix.Socket
代替,您可以使用
Plug.Conn
is not available in Phoenix.Channel
. Channels rely on Phoenix.Socket
instead and you can use Phoenix.Token
for authentication.
此处是有关如何在Phoenix中对频道进行身份验证的教程.
Here's a tutorial on how to authenticate channels in Phoenix.
这篇关于在Phoenix的Elixir中,如何使用Phoenix.Channel在其他模块中获取会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文