The store will not work correctly when cookies are disabled.
- Home
- Blog
- 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);
}
December 6, 2021 | View: 272
Copyright © 2025 Tridhya Tech Limited, Inc. All rights reserved.