Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 ?

like image 665
Cuong Ta Avatar asked Mar 13 '23 19:03

Cuong Ta


1 Answers

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.

like image 133
AbM Avatar answered Apr 27 '23 22:04

AbM