$this->tokenVerifier =
$tokenVerifier;
} public function createRememberMeCookie(UserInterface
$user): void
{ $series =
random_bytes(66
);
$tokenValue =
strtr(base64_encode(substr($series, 33
)), '+/=', '-_~'
);
$series =
strtr(base64_encode(substr($series, 0, 33
)), '+/=', '-_~'
);
$token =
new PersistentToken($user::
class,
$user->
getUserIdentifier(),
$series,
$tokenValue,
new \
DateTimeImmutable());
$this->tokenProvider->
createNewToken($token);
$this->
createCookie(RememberMeDetails::
fromPersistentToken($token,
time() +
$this->options
['lifetime'
]));
} public function consumeRememberMeCookie(RememberMeDetails
$rememberMeDetails): UserInterface
{ if (!
str_contains($rememberMeDetails->
getValue(), ':'
)) { throw new AuthenticationException('The cookie is incorrectly formatted.'
);
} [$series,
$tokenValue] =
explode(':',
$rememberMeDetails->
getValue());
$persistentToken =
$this->tokenProvider->
loadTokenBySeries($series);