How can I check customer is logged in or not? If customer is not logged in then how to redirect him to the login page?
I want to do this from .phtml
file. So please help me as per that.
loginmagento2redirect
How can I check customer is logged in or not? If customer is not logged in then how to redirect him to the login page?
I want to do this from .phtml
file. So please help me as per that.
Best Answer
If you want to do it directly from
.phtml
file use following code:Then after login you will be automatically redirected to current view.
But using Object Manager isn't good practice. You should use dependency injection whenever possible.