Skip to content

Instantly share code, notes, and snippets.

@6ui11em
Created July 17, 2018 14:04
Show Gist options
  • Save 6ui11em/f13700957f8d7208ad0428dfd01f3edd to your computer and use it in GitHub Desktop.
Save 6ui11em/f13700957f8d7208ad0428dfd01f3edd to your computer and use it in GitHub Desktop.
Magento 2: Check if customer is logged in #magento2 #cache #customer
// To avoid problems with full page cache
// https://github.com/magento/magento2/blob/4d2609343a950e9ee6b50cc4444469d50d82b139/app/code/Magento/Customer/Block/Account/Customer.php#L52
public function customerLoggedIn()
{
return (bool)$this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment