Skip to content

Fails to load current session on redirect #1

@bradrf

Description

@bradrf

I'm very new to using Phoenix LiveView, so take this with a large grain of salt. I have Live Sessions working (super easy—thank you!), but they appear to not provide the current session when using push_redirect. The session available in the destination LiveView appears to be the default values until the page is refreshed to force a full request made which then loads the session values (including the "user_id" added from the previous page). Is there some other mechanism I should be utilizing when navigating across LiveViews to ensure the session is available?

Example of session from redirect:

%{
    :__opts__ => [
      clean_interval: 60000,
      lifetime: 172800000,
      table: :phoenix_live_sessions,
      pub_sub: MyApp.PubSub,
      signing_salt: "XXX"
    ],
    :__sid__ => "XXX",
    "_csrf_token" => "XXX"
  }

And then as it's populated following the page reload:

%{
    :__opts__ => [
      clean_interval: 60000,
      lifetime: 172800000,
      table: :phoenix_live_sessions,
      pub_sub: MyApp.PubSub,
      signing_salt: "XXX"
    ],
    :__sid__ => "XXX",
    "_csrf_token" => "XXX",
    "user_id" => 87632            // <--- the ID from the stored session from previous page
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions