Goldfish is a database session store that implements the Plug.Session.Store behavior.
- Goldfish can be installed by adding
goldfish
to 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 changestore
to 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 goldfish
You should see this output
* creating priv/repo/migrations/20191224004432_goldfish_sessions.exs
Then migrate your database to create the table
mix ecto.migrate
That's it! You're ready to start using Goldfish to store your user sessions.