Search code examples
symfonycookiessession-cookiessetcookieremember-me

Why am i seeing multiple set-cookie headers?


I'm currently attempting to get the symfony 2.6 remember me functionality to work for my project. I've enabled it exactly according to the cookbook and i can see in my login_check response when using the symfony profiler the remember me cookie being set in the set-cookie header, however this is not shown when i inspected the response in chrome and safari, i only see the PHPSESSID and _ga values in the set-cookie header. I then looked at the response in charles proxy and discovered that there were instead two set-cookie headers, one with the PHPSESSID and _ga and another with the REMEMBERME.

So why am i seeing multiple set cookie headers? Is ok to see multiple set cookie headers as it seems browsers only respect the first header they see? And if you've happened to run into this issue before, how do i get my remember me to work? Thanks.


Solution

  • So after diving deep into symfony's inner workings, I was able to determine a few things. First, multiple set cookie headers is actually fine and quite standard. Secondly, my problem was because i was setting the path of my cookie to "/.*", which was not a valid path and thus the cookie was kicked out. By changing the path to "/" instead I managed to get everything working perfectly.