0

I have a login script using a php session under mydomain.com/login.php . Whenever a user accesses something inside the subfolder mydomain.com/internal/ I would like to automatically check whether he is logged in (with a custom php script) in order to redirect him to the login page if he's not logged in. Is that somehow possible?

In case it is easier, I would be happy to simply run the custom check-logged-in script before any php script is called under the whole domain.

I am using apache2 on a debian machine.

PS: I am currently adding an include statement for the checked-logged-in script at the head of each file in the internal subfolder. But this is a bit tedious and has the disadvantage of being rather prone errors (if I forget it when adding a new site).

0

Have a look at the php.ini setting auto_prepend_file. It can also be set using php_flag in your apache configuration so it happens only for one virtualhost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.