Jasper Rooduijn
Jasper Rooduijn

Reputation: 141

Symfony session (stand alaone) cookiename

I use the Symfony http foundation stand alone (aka i installed the http-foundation package with composer inside my non-symfony project). Ik would like to change the name of the session cookie. What would be my best way to achieve this?

I read a lot of items regarding this issue, most of them are about configuring the cookie name in the Symfony config.yml settings file which i do not have (stand-alone usage).

Any tips?

Upvotes: 2

Views: 2336

Answers (2)

Ousmane
Ousmane

Reputation: 2921

In Symfony 6.4 you can change the cookie session name in the framework.yaml file :


#framework.yaml

framework:
    session:
        name:   YOUR_SESSION_NAME_HERE

source : https://symfony.com/doc/current/reference/configuration/framework.html#name-1

Upvotes: 0

Igor Shumichenko
Igor Shumichenko

Reputation: 404

You can use Session::setName() instead of session_name().

See this here for Symfony 5.3 and here for Symfony 6 & more

Upvotes: 1

Related Questions