Answer the question
In order to leave comments, you need to log in
Symfony2 programmatic authorization and remember me?
With programmatic authorization in symphony
$token = new UsernamePasswordToken($user, null, 'secured_area', array('ROLE_USER'));
$this->get('security.context')->setToken($token);
Answer the question
In order to leave comments, you need to log in
It probably won't be easy. I would look somewhere in the direction of this:
\Symfony\Component\Security\Http\RememberMe\PersistentTokenBasedRememberMeServices
If you want to set a cookie, most likely you will want to read it, for each request - symfony2 docs will help you, for example , here or here
, but all this is cumbersome, maybe it's easier to implement from the box?
If you explicitly want "as in symfony" then obviously you need to find "as in symfony" - https://github.com/symfony/Security/blob/master/Ht...
$series = base64_encode($this->secureRandom->nextBytes(64));
$tokenValue = base64_encode($this->secureRandom->nextBytes(64));
$this->tokenProvider->createNewToken(
new PersistentToken(
get_class($user = $token->getUser()),
$user->getUsername(),
$series,
$tokenValue,
new \DateTime()
)
);
$response->headers->setCookie(
new Cookie(
$this->options['name'],
$this->encodeCookie(array($series, $tokenValue)),
time() + $this->options['lifetime'],
$this->options['path'],
$this->options['domain'],
$this->options['secure'],
$this->options['httponly']
)
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question