Check session variable before delivering cached page

thank you for your answer @odessite‍ .

All I want to do is make sure that for EVERY request (no matter if the page user wants to visit is cached or not) there is a simple check before that just looks at the session and checks if a certain variable is set. If that variable is set, we’re good to go, user can see the page (from cache or not). If the variable is not set, the user should be redirected to a „custom login“ page where he can submit a form that will in turn set that variable in the session.

The current implementation already does that, BUT it only works in development mode and the code for checking the session variable is not invoked on requests with production mode turned on (whenever a page is delievered from cache).

Do you think implementing it as a widget can solve that?

 

thank you for your help!