You just do IO.inspect("something") and check the output in the browser console.
You can safely ignore this. More details here: https://github.com/bartblast/hologram/issues/275 The problem will be resolved once Snabbdom is vendored (which is planned to eliminate the Node/npm dependencies).
Thanks @bartblast. Is my session supposed to be prepopulated? I saw that Server.from(conn) appears to extract it, but I’m not having success finding my authenticated ”user”. Only some CSRF tokens in there.
I have sort of figured things out. My app is mixed phx liveview and hologram and the session cookie gets stored in an encrypted state, which is what the hologram page is able to access.
Since there is not easy access to Plug.Session decryption (or conn) in this context things get a little complicated. I can think of a couple okay workarounds. Not sure if there is a known good pattern to handle this? I’m thinking I can either add limited unencrypted data to the session (not secure…) on login OR pull in some decryption flows Another issue is determining whether or not the user is logged in to begin with.
Hologram has full access to all data needed to correctly read and write to the Phoenix session via Plug.Conn.get_session() and Plug.Conn.put_session(). The framework is designed for seamless interoperability with Phoenix - session data should work identically whether you’re using LiveView or Hologram. If certain session values that are visible in LiveView are missing in Hologram, that’s probably a bug and needs to be investigated.
The fact that you’re seeing user_token but not user suggests something specific about how your authentication system stores data in the session. It’s possible that the user value is being stored differently (or conditionally) between LiveView and regular requests.
Can you create a basic repo that reproduces the problem? This will help me track down the issue and apply the fix. A minimal example that shows:
A LiveView route where you can see the full session data (including user)
A Hologram page route where the same session data should be visible but isn’t
This will make it much easier to debug what’s happening with the session handling. Getting this fixed will also benefit other users who might run into similar issues when mixing LiveView with Hologram pages in the same application.
I figured it out (again ). I’m using ash_authentication which apparently works by injecting ephemeral data into the session value within an ash_authentication_live_session, i.e. it doesn’t actually store the values in the cookie–see the source code for generate_session. I inspected the session on a route outside of the live session and only saw the user_token as we observed on the Hologram page. Apologies, I am new-ish to Ash and am still learning a lot about the ecosystem.
As Hologram pages define their own routes, I’m not so sure if it’s possible to take advantage of the generated session data from Ash. More to look into