Re: How to retrieve login state within Hydrogen?

How to retrieve login state within Hydrogen?

New Member
5 0 0

I have user authentication setup within my Hydrogen app. I have a page that needs to know if a user is signed in before navigating them to the next page. If the user is signed in, they are directed to checkout. But if the user is not logged in, they are directed to a page with a signup form.


There is a cookie of boolean type called "logged_in" that is sent from the Shopify server and stored in my browser. However, since it is "httpOnly" and "Secure", I am having a hard time pulling it into my Hydrogen component, and using it for this purpose. 



I need a way to check if a customer is signed in on Hydrogen, before navigating them to another page.



Reply 1 (1)

Shopify Partner
63 3 4

In the cart page, when someone click on go to checkout you can check if he is logged in...

Look in the account files and see how they determine if someone is logged in or not, and use the same code, and then afterwards redirect to checkout.


You can't block the checkout.


But you can with checkout settings block user from buying if they didn't sign up.