2

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?

Jasper Rooduijn
  • 141
  • 1
  • 5
  • just use the `construct` to configure: name, lifetime, domain, path ect look at [the api][1] [1]: http://api.symfony.com/3.1/Symfony/Component/HttpFoundation/Cookie.html#method___construct – T. Abdelmalek Oct 03 '17 at 07:44
  • Thank! I would use this function to set a new cookie! But can i also use this to change the name of the cookie used for session? I mean the cookie with the name 'PHPSESSID'. If true, i'm not sure how to. – Jasper Rooduijn Oct 03 '17 at 07:54
  • Just plain php, see https://stackoverflow.com/questions/964272/how-to-rename-phpsessid – Greg Oct 03 '17 at 08:05
  • That did the trick! I did not think this was a plain PHP issue. Was searching in the complete wrong corner :-) Thanks. – Jasper Rooduijn Oct 03 '17 at 08:30

1 Answers1

1

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

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

Elikill58
  • 4,050
  • 24
  • 23
  • 45
Igor Shumichenko
  • 394
  • 3
  • 12