Symfony5.4 → 6.4 RememberMe is not recognized and logs me out when I set it as a cookie

Expected behavior

In order to upgrade from Symfony 5.4 to Symfony 6.4, we have removed the currently deprecated “TokenBasedRememberMeServices” and implemented the new RememberMe autologin feature.
I have written the following code in an acceptance test for RememberMe’s auto-login feature.

Issue

MyPage::newInstance($this->getRouter(), $driver); process is correct to log in and transition to MyPage, but it logs out and transitions to a different page.

<?php

namespace TestsSecurity;

use FacebookWebDriverCookie;
use FacebookWebDriverSupportEventsEventFiringWebDriver;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationRequestStack;
use SymfonyComponentSecurityCoreSignatureSignatureHasher;
use SymfonyComponentSecurityHttpRememberMeResponseListener;
use AppEntityUser;

class AutoLoginTest extends WebTestCase
    public function testAutoLogin(): void
    {
        /** @var User $user */
        $user = $this->registerUser();

        $handler = new SignatureRememberMeHandler(
            signatureHasher: static::getContainer()->get(SignatureHasher::class),
            userProvider: static::getContainer()->get(UserRepository::class),
            requestStack: $this->createConfiguredMock(
                RequestStack::class,
                ['getMainRequest' => $request = new Request()]
            ),
            options: [
                'name'     => 'REMEMBERME',
                'lifetime' => 604800,
            ],
        );
    }
    $handler->createRememberMeCookie($user);

    // create web driver for acceptance test
    $driver = $this->createWebDriver;

    // page object for no login user
    HomePage::newInstance($this->getRouter(), $driver);
    $cookie = Cookie::createFromArray(
        [
            'name'     => 'REMEMBERME',
            'value'    => $request->attributes->get(ResponseListener::COOKIE_ATTR_NAME)->getValue(),
            'path'     => '/',
            'domain'   => null,
            'expiry'   => time() + 604800,
            'secure'   => true,
            'httponly' => false,
        ]
    );
    $driver->manage()->addCookie($cookie);
    // -- ERROR --  page object for login user
    MyPage::newInstance($this->getRouter(), $driver);
remember_me:
    secret: secret
    lifetime: 604800
    path: /
    domain: ~
    name: REMEMBERME
    signature_properties: ['username', 'password']
<?php

namespace AppSecurity;

use SymfonyComponentPropertyAccessPropertyAccess;
use SymfonyComponentSecurityCoreSignatureSignatureHasher;

class SignatureHasherFactory
{
    public static function create(array $signatureProperties): SignatureHasher
    {
        $propertyAccessor = PropertyAccess::createPropertyAccessor();

        return new SignatureHasher($propertyAccessor, $signatureProperties, 'secret');
    }
}
SymfonyComponentSecurityCoreSignatureSignatureHasher:
    factory: ['AppSecuritySignatureHasherFactory', 'create']
    arguments:
        - ['getUsername', 'getPassword']
    public: true

Why is my RememberMe not working?

Implemented the above

New contributor

lomlom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật