This component can be used on any page where you want to check if a user is logged in.
If not logged in, they will be redirected to the login page.
The useEffect
hook waits until things are ready before checking the session status
I use this in next.js apps but it might work in react apps with slight modifications.