wc_add_notice() not working, notice is not printed

Use case is the following : I have a WooCommerce shop with a separate shop page for companies. If a user tries to access this shop without being logged in and without being a company, I redirect to the login page and display a message, by taking advantage of the WC notice system.

At first, I never saw my message until I made some tests and I could see it only if I was logged in.

I took me a while to figure it out, but this was only caused by the absence of a WooCommerce session.
Indeed, those notices are stored in the session, and if you’re new and have no session… then you have no message !
Session is created when you log in or when you add an item to your cart, but if you want to use notices before any of this happens, you have to start your session manually.

I found this on Stack Overflow, and that fixed my issue :

function registering_my_session()
    if ( ! WC()->session->has_session() )
add_action('init', 'registering_my_session');