We don’t pass session information to the channel for a number of reasons, and instead favor token auth. Relying on the session is problematic because:
1. The Plug API breaks down after the connection is upgraded to a websocket (you can’t write to the session)
2. Channels are multiplexed, so if you join 10 channels on a single connection, you need to auth those topics anyway outside of the session (via tokens)
3. Channels are meant to be multiplatform, so your mobile client native apps likely won’t have a cookie session, and will need token auth.
We’re working to provide an API to make token generation and auth easier, but for now you need to pass up the data you require in `socket.join` on the client.
If you just need to pass a few bits of data up, rendering on the layout and accessing via JS is an option:
<script …
var SocketExports = <%= %{foo: %{…}} |> JSON.encode! %>;
…
socket.join(“the:topic”, {foo: SocketExports.foo, …}, function(chan){ ...
</script>
More elaborate data requirements could make an auth ajax request up or some JSON data and then that can be passed to `socket.join`
Our story should improve here soon. Hope that helps!
Chris