0

I have to setup a remember me login with my Symfony2 project and I have to setup my firewall in security.yml

I did something like that

        remember_me:
            secret: '%secret%'
            lifetime: 604800
            path: ^/

I was wondering what is the difference between / and ^/ for the path parameter ?

Fr0z3n7
  • 2,548
  • 2
  • 14
  • 15
  • 1
    The `path` parameter at the end of the day is used as `path` parameter for [`setcookie()`](http://php.net/manual/pl/function.setcookie.php) function used to create "rememberme" cookie. `^/` makes no sense in this context. – Crozin Jul 27 '16 at 07:57
  • Thanks you for your comment, this is now clear – Fr0z3n7 Jul 27 '16 at 08:02

2 Answers2

4

Imagine your url is this one : https://example.com/

^/ <=> catch all path that start with "/"

/ <=> catch all path that are preceded by "/"

So in this case there is no difference, both are matching all path after the last "/" of https://example.com/

In your case, you have to put "/" instead of "^/" because "^/" makes no sense in this context.

According to the doc :

path (default value: /)

The path where the cookie associated with this feature is used. By default the cookie will be applied to the entire website but you can restrict to a specific section (e.g. /forum, /admin).

Community
  • 1
  • 1
Goku
  • 2,157
  • 2
  • 16
  • 31
-1

Take a look at the documentation. The relevant passage quotes:

Prepending the path with ^ means that only URLs beginning with the pattern are matched. For example, a path of simply /admin (without the ^) would match /admin/foo but would also match URLs like /foo/admin.

Emanuel Oster
  • 1,296
  • 10
  • 21
  • 1
    This fragment of documentation refers to `access_control.path` which takes a regular expression, not cookie parameter which is a simple string. – Crozin Jul 27 '16 at 07:55