Skip to content

Session dies and doesnt work after a while with Symfony 6.3 and FrankenPHP Caddy worker mode enabled #527

@beejaz

Description

@beejaz

Hi,

I've recently migrated from Symfony 6.3 on nginx & php-fpm to caddy & frankenphp with this repo.

Im using PDOSessionStorage in Symfony with sessions in a MySQL db. I have the frontend as a VueJS application that redirects same domain request /api endpoint to caddy backend with frankenphp in Kubernetes.

What happens is that the user is able to login, a session cookie is created. When another user (or same user but with new browser/session id) tries to login, it doesnt work, it gives HTTP 401 and no session is set. Later on, the session for the first user also dies and cookie is removed (lifespan is 7 days but it gets removed before that). If I reload/redeploy the container in Kubernetes, everything starts working again and then repeats.

Ive checked #471 and my settings are in the same order as this.

Turning off worker mode seems to fix the issue. If i set env "FRANKENPHP_CONFIG" to empty string instead of import worker.Caddyfile it does seem to work as expected again where I can login with several clients and keep the session alive for all of them.

my frankenphp/worker.Caddyfile looks like this:

worker {
	file ./public/index.php
	env APP_RUNTIME Runtime\FrankenPhpSymfony\Runtime
}

My composer.json has "runtime/frankenphp-symfony": "^0.1.1", and in the production container I have these versions:

/app # frankenphp -v
FrankenPHP v1.0.0 PHP 8.3.0 Caddy v2.7.5 h1:HoysvZkLcN2xJExEepaFHK92Qgs7xAiCFydN5x5Hs6Q=

I dont know what to do or what it could be. Im new to FrankenPHP and worker mode. Any ideas? Can I provide any more details to ease the troubleshoot?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions