I’m facing a weird issue with my PHP/Symfony application.
PHP version : 8.1.24
Symfony version : 6.3
I used the standard Symfony cli to generate the application.
When working on local env, no issue.
But when deployed on a remote server (nginx through Docker), after a while, EVERY POSTS start firing random “Warning:session_id(): Session id cannot be changed after headers have already been sent“. Usually resending the post is working, but sometimes not.
It happens with EVERY posts in app, whether it’s login, easy admin or custom forms.
If I reboot the server, the error disapear (and returns after few minutes)
I didn’t find any solution.
I searched for print or dump : I have not (and since it’s failing even for easy admin generated classes, I doubt it’s the solution). No blanks left before <PHP tag (and again, probably not the solution here).
Thanks for your help.
I checked for blank Space before <PHP and for print/dump fonction in the code.
Full stack trace :
Warning: session_id(): Session ID cannot be changed after headers have already been sent
ErrorException
Show exception properties
in vendor/symfony/http-foundation/Session/Storage/Proxy/AbstractProxy.php (line 84)
in vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php -> setId (line 191)
in vendor/symfony/http-foundation/Session/Session.php -> setId (line 185)
in vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php -> setId (line 84)
in vendor/symfony/http-foundation/Request.php -> SymfonyComponentHttpKernelEventListener{closure} (line 723)
in vendor/symfony/http-foundation/Request.php -> getSession (line 740)
in vendor/symfony/security-http/Firewall/ContextListener.php -> hasPreviousSession (line 90)
in vendor/symfony/security-bundle/Debug/WrappedLazyListener.php -> authenticate (line 46)
in vendor/symfony/security-http/Firewall/AbstractListener.php -> authenticate (line 26)
in vendor/symfony/security-bundle/Security/LazyFirewallContext.php -> __invoke (line 60)
in vendor/symfony/security-bundle/Debug/TraceableFirewallListener.php -> __invoke (line 73)
in vendor/symfony/security-http/Firewall.php -> callListeners (line 95)
in vendor/symfony/event-dispatcher/Debug/WrappedListener.php -> onKernelRequest (line 116)
in vendor/symfony/event-dispatcher/EventDispatcher.php -> __invoke (line 220)
in vendor/symfony/event-dispatcher/EventDispatcher.php -> callListeners (line 56)
in vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php -> dispatch (line 139)
in vendor/symfony/http-kernel/HttpKernel.php -> dispatch (line 158)
in vendor/symfony/http-kernel/HttpKernel.php -> handleRaw (line 76)
in vendor/symfony/http-kernel/Kernel.php -> handle (line 197)
in vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php -> handle (line 35)
in vendor/autoload_runtime.php -> run (line 29)
require_once(‘/var/www/caestats/vendor/autoload_runtime.php’)
in public/index.php (line 5)