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