Skip to content

Commit bd03bad

Browse files
committed
Added "remember me" feature in the login form
1 parent ecf3f85 commit bd03bad

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

config/packages/security.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ security:
4444
# session (for example when the users access directly to the login page).
4545
default_target_path: blog_index
4646

47+
# Reference: https://symfony.com/doc/current/security/remember_me.html
48+
remember_me:
49+
secret: '%kernel.secret%' # required
50+
lifetime: 604800 # 1 week in seconds
51+
# by default, the feature is enabled by checking a
52+
# checkbox in the login form (see below), uncomment the
53+
# following line to always enable it.
54+
#always_remember_me: true
55+
4756
logout:
4857
# The route name the user can go to in order to logout
4958
path: security_logout

templates/security/login.html.twig

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
<label for="password">{{ 'label.password'|trans }}</label>
2929
<input type="password" id="password" name="_password" class="form-control" />
3030
</div>
31+
<div class="form-group">
32+
<label>
33+
<input type="checkbox" name="_remember_me" checked/>
34+
Keep me logged in
35+
</label>
36+
</div>
3137
<input type="hidden" name="_target_path" value="{{ app.request.get('redirect_to') }}"/>
3238
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>
3339
<button type="submit" class="btn btn-primary">

0 commit comments

Comments
 (0)