Is there a trick to keeping your user logged in with the Symfony EasyAdmin bundle? I have no problem when running things locally, but when working in a production environment, weird things happen, and I see no errors in the logs.

Sometimes, when I log in, I’m 302 redirected right back to the login page. Sometimes, it actually takes me to the admin, but the moment I click on any link, I'm logged out. I can't seem to stay logged in.

#PHP #Symfony

@ramsey In the projects where we use EasyAdmin, that doesn't happen… Is there perhaps something wrong with your configuration? A conflict or something?
@tobiaskoengeter I don’t know. I don’t have this problem in local dev, so I can’t debug it.
@tobiaskoengeter This has happened before (about a year ago), and I gave up working on it, so I started over a few weeks ago, and now, it’s happening again. This is just a vanilla EasyAdmin install. I haven’t changed anything from the defaults.
@ramsey That’s odd! So it can’t really be a ‘special configuration’. Could it be down to the sessions, and that in turn to the browser settings?
@tobiaskoengeter I think it must be something to do with the sessions, but I’ve tried in Safari, Vivaldi, and Firefox, and I have this problem in all three, so if it’s a browser setting, it’s something I’ve enabled in all of them.
@tobiaskoengeter But it’s also weird that none of the browsers have this problem when I run it locally.
@tobiaskoengeter I’m giving up for the night. Tonight was the first time I had deployed it to prod since I began working on this iteration of it, and I forgot this had been a problem in the past. 😞

@ramsey @tobiaskoengeter what's your session config for prod? I don't remember if there's some default difference in Symfony...

Any difference from local to prod?
Maybe HTTPS + secure cookies?

@alessandrolai @ramsey Or a VPN that interferes in any way?
@ramsey it's definitely session configuration. Maybe it's set to file and it cannot write. Or perhaps it's redis or something else that is evicting keys or something. Also check if the domain is configured for cookies.
@luceos Ah ha! I have multiple containers running, and I bet this has to do with sessions writing to files.

@luceos
@tobiaskoengeter @alessandrolai This was it!

Can you tell I haven’t set up a website from scratch in a loooong time. 😅

I just configured it to use PostgreSQL as the session store, and everything is fine, now. https://symfony.com/doc/current/session.html#store-sessions-in-a-relational-database-mariadb-mysql-postgresql

Sessions (Symfony Docs)

The Symfony HttpFoundation component has a very powerful and flexible session subsystem which is designed to provide session management that you can use to store information about the user between req…

@ramsey @luceos @tobiaskoengeter Ahah, bad assumption from the old times... With containers you don't have a shared disk, so no shared sessions by default 😂