FireBear Blog
  • M2 Extensions
    • Improved Import
    • SAP Business One
    • ICP
  • Blog
    • Must have M2 Extensions
    • M2 Extensions Reviews
    • M2 Extensions Compared
    • Magento 2 B2B
    • Magento® 2 Extensions
    • Magento Performance
    • Magento SEO
    • Magento 2
      • Magento 2 Tutorial
      • Magento 2 Extensions
      • Magento 2 Cookbook
    • E-Commerce
    • Our extensions
    • Magento tips
    • Ethereum
    • BitCoin
  • Contact Us
  • Services
    • ERP Integration
    • CRM Integration
    • Accounting integration
    • Migration to M2

Search on Firebear Studio blog

Firebear Studio

How to check if customer is logged into Magento 2

December 4, 2015 - Fire development, Magento 2

Magento 2 Development

In Magento 2, to check if customer is logged in, use the following code:

1
2
3
4
5
6
/** @var \Magento\Framework\App\ObjectManager $om */
$om = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Framework\App\Http\Context $context */
$context = $om->get('Magento\Framework\App\Http\Context');
/** @var bool $isLoggedIn */
$isLoggedIn = $context->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);

Source (Stackexchange Question)(Marius♦ and Mage2.PRO)

More tips from the Cookbook

Related posts

  • How to Import Customers & Customer Addresses to Magento 2How to Import Customers & Customer Addresses to Magento 2
  • Magento 2 B2B Company Guide: Revealing Company Structure & ImportMagento 2 B2B Company Guide: Revealing Company Structure & Import
  • Amasty ChatGPT AI Content Generator for Magento 2Amasty ChatGPT AI Content Generator for Magento 2
  • Magento 2 Release NotesMagento 2 Release Notes
  • Adobe (Magento 2) Commerce and Cloud (Enterprise Edition) Specific FeaturesAdobe (Magento 2) Commerce and Cloud (Enterprise Edition) Specific Features
  • A Complete Guide to Shopify Customer ImportA Complete Guide to Shopify Customer Import
  • Reputon Amazon Importer Review: How to Connect Shopify to Amazon in a Few ClicksReputon Amazon Importer Review: How to Connect Shopify to Amazon in a Few Clicks
  • CopyAI Review 2023CopyAI Review 2023
Post Tags:customerloginmagento 2Magento 2 Developer’s Cookbook
Homepage » Fire development » How to check if customer is logged into Magento 2
← Previous Post Next Post →


Index

  • Magento 2 In-Depth Review
  • Magento 2 Import & Export Guide
  • Must have Magento 2 Extensions
  • Magento 2 Extensions Reviews
  • Magento 2 Extensions Comparisons
  • Magento 2 Cookbook
  • Magento® 2 Tutorial
  • Magento 2 Templates
  • Improved Import Magento 2 Extension
  • Improved Configurable Product Magento 2 Extension

Newsletter

customer

  • Magento 2 Custom Order Number by Ulmod

    Customs numbers are useful to ecommerce businesses and look more professional to customers.  It helps you provide a positive impact… Read more…

  • How to get default billing and shipping address by customer in Magento 2

    The following article sheds light on how to get default billing and shipping address by a customer in Magento 2.… Read more…

  • Magento 2 Customer Approval by Ulmod

    Many stores owners always complain about their Magento 2 webshop getting flooded with fake customer registrations and their get tired… Read more…

  • Magento 2 Minimum Order Amount for Customer Group Extension by MageAnts

    It happens at times that customers just take a stroll on your online store and place an order of a… Read more…

  • How to get Customer in product view in Magento 2

    You can get customer_id, getName(), and getEmail() in the product view in Magento 2 directly from customer session. Utilize the… Read more…

  • How to check if customer is logged into Magento 2

    In Magento 2, to check if customer is logged in, use the following code: [crayon-6618e5b39ac9f844981930/] Source (Stackexchange Question)(Marius♦ and Mage2.PRO)… Read more…

Top E-Commerce

Don't Miss

Magento 2 Share Cart extension by Mageplaza

On November 11, 2020
  • Contact Us
  • Archives
  • Magento extensions
© 2018 Firebear Studio
Magento® is a registered trademark of Magento Inc.