Preserve params between pages

Hii everyone. Fairly new to Elixir/Phoenix

Phoenix App contains 2 live pages, openings_live and job_application and uses github Uberauth for auth.
openings_live serves as landing page with list of positions with buttons where user can login to GitHub,
job_application is a form where user can apply to desire position.

In router I serve something like this:

scope "/", LandingWeb do
    pipe_through :browser
    # landing page main route
    live "/", JobLive.OpeningsLive.Index, :index

# github auth scope
  scope "/auth", LandingWeb do
    pipe_through :browser
    # job application route - protected
    live_session :default, on_mount: LandingWeb.UserAuthLive do
      live "/job_openings/:id/apply", JobApplicationFormLive, :index

    # github auth routes
    get "/:provider", GithubAuthController, :request
    get "/:provider/callback", GithubAuthController, :callback

After user clicks on the login button on landing page it takes them to the GitHub page and use their profile data.
When GitHub returns the user to the landing page, it should take the user to job_application form.

The question is, how I can preserve, between page reloads, job_id from openings_live so I can use it in job_application form ? I could use session for temporary storing job_id and read it in mount() fun.

Is there better solution for this?


Hello and welcome, I reformatted the post to be more readable…

Please remember to wrap your code with ```, like in markdown

BTW I think session is a good place for your use case