How to get customer id when page cache is enabled?

How to get customer id when page cache is enabled?

Use below code in your php file

public function __construct(

\Magento\Framework\App\Http\Context $httpContext,

)

{

$this->httpContext = $httpContext;

}

public function isCustomerLoggedIn()

{

return (bool)$this->httpContext-> getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);

}



Copyright © 2024 Tridhya Tech Limited, Inc. All rights reserved.