Goldfish is a database session store that implements the Plug.Session.Store behavior.
- Goldfish can be installed by adding
goldfishto your list of dependencies inmix.exs:
def deps do
[
{:goldfish, "~> 0.1.0"}
]
end- Edit your endpoint file (for example
lib/my_app_web/endpoint.ex) and changestoreto useGoldfish.Store
plug Plug.Session,
store: Goldfish.Store,
key: "_my_app_key"- Configure Goldfish (for example in
config/config.exs) to use your repo of choice to store your user sessions
config :goldfish,
repo: MyApp.Repo- Generate the migration to create your session table and migrate your databse
mix goldfishYou should see this output
* creating priv/repo/migrations/20191224004432_goldfish_sessions.exsThen migrate your database to create the table
mix ecto.migrateThat's it! You're ready to start using Goldfish to store your user sessions.