Redirect based on Cookie leads to Error after WooCommerce payment

I want to make sure every user does only get access to my webshop after visiting the home page.
Therefore, the home page sets a cookie

My child-theme’s functions.php includes a hook to template_redirect to make sure all sites (except the home page) will check for the cookie.
If it is not set, it will redirect the user to the home page.

This basically works – every time the user tries to access the shop directly, he will be redirected to the home page.

The error happens after an order has been made. I tested this via PayPal checkout. As soon as the payment has been made and the user clicks the button to return to the shop to see the thank you page, he is redirected to the front page.

I checked for my cookie in chrome and it does exist, but still I get redirected to the home page.

Since I’m also not sure if my approach is efficient I would be thankful for your opinion on how to do better.