Protect Your Pages

If you already have some PHP pages that you want to protect, or you are using AS as a base and adding new pages to it, you will probably want to protect those files and allow access to authenticated users only. To do so, just add the following code snippet at the very top of your PHP file and you are good to go:


include 'ASEngine/AS.php';

if (! app('login')->isLoggedIn()) {

The code above will just check if user is logged in, and redirect him to login.php if he is not logged in.

If you want to redirect users to any other page (instead of login.php), just update the redirect function and pass the page (or external URL) you want.

Note! Make sure that you place the code snippet from above at the very top of your php file. There shouldn't be any HTML (not even a empty space) before it since that will prevent PHP session to start properly.

Redirect to custom page after login

Check login configuration section for more information.