I want to check if a customer is logged or not. And if he/she logged, I want to get the customerId. I just googled but I could find 2 ways.
One is to use CustomerSession:
Magento\Customer\Model\Session
Another one is to use Customer\Model\Context.
Magento\Customer\Model\Context::CONTEXT_AUTH
Which is right way? These 2 articles show different way. I am really confusing what I should use. http://www.blogtreat.com/get-logged-in-customer-data-in-magento-2/
Magento 2: get customer id of logged in user with cache enabled
Thanks.