我以记住我的身份配置了Symfony 4项目。它正在创建一个带有过期日期的REMEMBERME cookie,但是一旦过期,我就不会注销。
Security.yaml
remember_me:
name: REMEMBERME
secret: '%kernel.secret%'
lifetime: 120
path: /en/admin
remember_me_parameter: remember_me
always_remember_me: true
token_provider: 'Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider'
登录树枝
<form action="{{ path('security_login') }}" method="post">
<div class="block block-themed block-rounded block-shadow">
<div class="block-header bg-gd-dusk">
<h3 class="block-title">Please Sign In</h3>
<div class="block-options">
<button type="button" class="btn-block-option">
<i class="si si-wrench"></i>
</button>
</div>
</div>
<div class="block-content">
<div class="form-group row">
<div class="col-12">
<label for="username">{{ 'label.username'|trans }}</label>
<input type="text" id="username" name="_username" value="{{ last_username }}" class="form-control"/>
</div>
</div>
<div class="form-group row">
<div class="col-12">
<label for="password">{{ 'label.password'|trans }}</label>
<input type="password" id="password" name="_password" class="form-control" />
</div>
</div>
<div class="form-group row mb-0">
<div class="col-sm-6 d-sm-flex align-items-center push">
<div class="custom-control custom-checkbox mr-auto ml-0 mb-0">
<input type="checkbox" id="remember_me" name="_remember_me" checked/>
<label for="remember_me">Keep me logged in</label>
</div>
</div>
<div class="col-sm-6 text-sm-right push">
<input type="hidden" name="_target_path" value="{{ app.request.get('redirect_to') }}"/>
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>
<button type="submit" class="btn btn-primary">
<i class="fa fa-sign-in" aria-hidden="true"></i> {{ 'action.sign_in'|trans }}
</button>
</div>
</div>
</div>
<div class="block-content bg-body-light">
<div class="form-group text-center">
<a class="link-effect text-muted mr-10 mb-5 d-inline-block" href="{{ path('user_signup') }}">
<i class="fa fa-plus mr-5"></i> Create Account
</a>
<a class="link-effect text-muted mr-10 mb-5 d-inline-block" href="{{ path('forgot_password') }}">
<i class="fa fa-warning mr-5"></i> Forgot Password
</a>
</div>
</div>
</div>
</form>
AdminController
public function index(PostRepository $posts): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
$user = $this->getUser();
return $this->render('admin/dashboard.html.twig', [
'user' => $user,
]);
}
用户角色
array:2 [▼
0 => "ROLE_ADMIN"
1 => "IS_AUTHENTICATED_FULLY"
]
我想念什么? REMEMBERME是自动删除的,如果删除PHPSESSID,则必须重新登录。但是,如果不手动删除PHPSESSID,它是否不起作用?