In my phoenix project I have the following action in controller which is responsible for signing out user:
def signout(conn, _params) do
conn
|> configure_session(drop: true)
|> put_flash(:info, "Signed out successfully!")
|> redirect(to: project_path(conn, :index))
end
The problem is that when I use configure_session(drop: true)
flash message is not appearing on the screen. How can I fix that?
Use clear_session/1
instead of configure_session/2
. Using :drop
on configure_session/2
will completely remove the session cookie and no cookie will be sent with the response.
clear_session/1
will remove all keys from the session, but keep the session cookie sent to the client. So you can still add your put_flash
into the session cookie after you have cleared it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With