Skip to content

Magento Checkout, Check if the user is logged-in

I have to redirect the user to our SSO login page ifhe is not logged-in during the checkout.

As suggested here, I added this check into my phtml file that overrides this vendor/magento/module-checkout/view/frontend/templates/onepage.phtml.

if(!$this->customerSession->isLoggedIn()) 

Debugging the code seems that this->customerSession is not present.
So, how can I check if the user is logged-in into this phtml file?