@@ -16,17 +16,29 @@ the session lasts using a cookie with the ``remember_me`` firewall option:
16
16
17
17
# app/config/security.yml
18
18
firewalls :
19
- main :
19
+ default :
20
+ # ...
20
21
remember_me :
21
22
key : " %secret%"
22
23
lifetime : 604800 # 1 week in seconds
23
24
path : /
25
+ # by default, the feature is enabled using
26
+ # a checkbox in the login form (see below),
27
+ # uncomment the below lines to always enable
28
+ # it.
29
+ # always_remember_me: true
24
30
25
31
.. code-block :: xml
26
32
27
33
<!-- app/config/security.xml -->
28
34
<config >
29
- <firewall >
35
+ <firewall name =" default" >
36
+ <!-- ... -->
37
+
38
+ <!-- by default, the feature is enabled using
39
+ a checkbox in the login form (see below),
40
+ add always-remember-me="true" to always
41
+ enable it. -->
30
42
<remember-me
31
43
key = " %secret%"
32
44
lifetime = " 604800" <!-- 1 week in seconds -->
@@ -40,11 +52,17 @@ the session lasts using a cookie with the ``remember_me`` firewall option:
40
52
// app/config/security.php
41
53
$container->loadFromExtension('security', array(
42
54
'firewalls' => array(
43
- 'main' => array(
55
+ 'default' => array(
56
+ // ...
44
57
'remember_me' => array(
45
58
'key' => '%secret%',
46
59
'lifetime' => 604800, // 1 week in seconds
47
60
'path' => '/',
61
+ // by default, the feature is enabled using
62
+ // a checkbox in the login form (see below),
63
+ // uncomment the below lines to always enable
64
+ // it.
65
+ //'always_remember_me' => true,
48
66
),
49
67
),
50
68
),
@@ -94,21 +112,30 @@ The ``remember_me`` firewall defines the following configuration options:
94
112
"Remember Me" feature is always enabled, regardless of the desire of the
95
113
end user.
96
114
115
+ ``token_provider `` (default value: ``null ``)
116
+ Defines the service id of a token provider to use. By default, tokens are
117
+ stored in a cookie. For example, you might want to store the token in a
118
+ database, to not have a (hashed) version of the password in a cookie. The
119
+ DoctrineBridge comes with a
120
+ ``Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider `` that
121
+ you can use.
122
+
97
123
Forcing the User to Opt-Out of the Remember Me Feature
98
124
------------------------------------------------------
99
125
100
126
It's a good idea to provide the user with the option to use or not use the
101
127
remember me functionality, as it will not always be appropriate. The usual
102
128
way of doing this is to add a checkbox to the login form. By giving the checkbox
103
- the name ``_remember_me ``, the cookie will automatically be set when the checkbox
104
- is checked and the user successfully logs in. So, your specific login form
105
- might ultimately look like this:
129
+ the name ``_remember_me `` (or the name you configured using ``remember_me_parameter ``),
130
+ the cookie will automatically be set when the checkbox is checked and the user
131
+ successfully logs in. So, your specific login form might ultimately look like
132
+ this:
106
133
107
134
.. configuration-block ::
108
135
109
136
.. code-block :: html+jinja
110
137
111
- {# src/Acme/SecurityBundle/ Resources/views/Security /login.html.twig #}
138
+ {# app/ Resources/views/security /login.html.twig #}
112
139
{% if error %}
113
140
<div>{{ error.message }}</div>
114
141
{% endif %}
@@ -128,7 +155,7 @@ might ultimately look like this:
128
155
129
156
.. code-block :: html+php
130
157
131
- <!-- src/Acme/SecurityBundle/ Resources/views/Security /login.html.php -->
158
+ <!-- app/ Resources/views/security /login.html.php -->
132
159
<?php if ($error): ?>
133
160
<div><?php echo $error->getMessage() ?></div>
134
161
<?php endif ?>
@@ -150,7 +177,7 @@ might ultimately look like this:
150
177
The user will then automatically be logged in on subsequent visits while
151
178
the cookie remains valid.
152
179
153
- Forcing the User to Re-authenticate before Accessing certain Resources
180
+ Forcing the User to Re-Authenticate before Accessing certain Resources
154
181
----------------------------------------------------------------------
155
182
156
183
When the user returns to your site, they are authenticated automatically based
0 commit comments