Assuming you have a authentication system in place to handle your users, you normal store the users data in the session store to keep track. You can find the default stores Phoenix includes here: Plug.Session – Plug v1.4.5
Assuming you use the Plug.Session.Cookie, your authentication system should use the methods Plug.Conn.put_session/3 and Plug.Conn.get_session/3 to save the users information and fetch it respectively. You can find more information here: Plug.Session.COOKIE – Plug v1.4.5 and Plug.Conn – Plug v1.4.5
The users information will be stored in the session and can be fetch in the html page using the connection (conn).
You can also store the user information elsewhere and send the users information in the assigns map inside the conn struct as @idi527 suggested . You can find more information here: Plug.Conn – Plug v1.4.5. You can add the users information in the assigns map when you render the page. Check the render/3 method here: Phoenix.Controller — Phoenix v1.8.8
So I’m getting the following error "protocol Phoenix.HTML.Safe not implemented for %Magnify.Coherence.User{meta: #Ecto.Schema.Metadata<:loaded, “users”>, "
I have the following in my view
def name(conn) do
case conn.assigns[:current_user] do
nil -> ""
name -> name
end
end