increade coookie time
This commit is contained in:
parent
0b4fe7f44a
commit
95fa74a2b0
1 changed files with 8 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace App\Controller;
|
||||
|
||||
use App\Form\UserNameFormType;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
@ -33,7 +34,13 @@ final class HomeController extends AbstractController
|
|||
$response->headers->clearCookie('username');
|
||||
return $response;
|
||||
}
|
||||
$response->headers->setCookie(new Cookie('username', $username));
|
||||
$response->headers->setCookie(
|
||||
new Cookie(
|
||||
name: 'username',
|
||||
value: $username,
|
||||
expire: new DateTimeImmutable('+1 year'),
|
||||
)
|
||||
);
|
||||
return $response;
|
||||
}
|
||||
$username = $request->cookies->get('username', self::DEFAULT_USERNAME);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue