|
I'm building a site where all pages need to be publicly viewable except for URLs starting with '/my-account'. So, '/my-account/change-password' etc. would only be allowed to be viewed by people who have logged in.
Information:
1. I'm using PHP sessions
2. My URLs get rewritten: '/my-account/change-password' would be rewritten to something like /changepassword.php
3. If a user logs in, $_SESSION['auth'] gets assigned the value of '1'
I'm wondering what the best way to go about this is; I could just go:
if ($_SESSION['auth'] != 1) /*display login*/
else { /*display the authorised page*/ }
That would be a bit irritating to type in for each page. Is there possibly a better way to do it?
Thanks
|