PW Protect Application AND Assets

Hello Kirupians,
I need to password protect my application along with all of its assets. The application needs to be able to log users in as well as log them out efficiently. Is there a way to use PHP to protect all of the assets and the app without having to use .htaccess? Currently the app is using .htaccess to authenticate users but I am unable to log the users out without having the user clear their authenticated sessions through their browsers options. Does anyone know if there’s a way to striclty use PHP to protect an application and all of its assets without having to log a user in via the apache login?
Thanks,
-P