How to allow entrance to page just for logged users

Hello, please how can I set up pages which can be visited just by logged users? Should I use for this purpose something like this?

$session = $sdk->getCredentials();
$authenticated = $session !== null;

I have table where I have data for users and each user has own user_id. Is it possible to connect with auth0 user_id?

Bcz I need to give user_id and check if is he/she logged in for each page which can be visited by logged user.

I cannot find it in documentation and I do loggin system first time.