网站访问控制

I'm currently working on adding a login system to an old website. Unfortunately, I'm new to web developments and can not find answers for the following questions: 1. How can I check if a user is logged in or not before serving his http requests. I do understand that in pho we just add session_start() follow by some checking statements. But the website I'm working on is really big and can would be tedious to add session check statement in every page. so is there a way to check if a user is logged in before serving his/her request?

The server is using nginx and the website is using php.

Thanks