increade coookie time #111

Merged
lubiana merged 1 commit from add-card into main 2025-07-16 17:53:16 +00:00
Showing only changes of commit 95fa74a2b0 - Show all commits

View file

@ -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);