How to redirect a user back to the page he was on after login?

Advanced Security - PHP Register/Login System Advanced Security - PHP Register/Login System / FAQ Last updated on Updated  Mar 13, 2019

By default, you can set the default redirect page per user role inside the configuration file.

However, if you just want to redirect your customers back to the page they tried to access before they were redirected to the login.php page, you will need to modify the application like following:

1) Add the following code to the login.php file, right below the AS.php file is included:

ASSession::set('prev_page', $_SERVER['HTTP_REFERER']);

2) Modify the userLogin method in ASLogin class by updating the respond function call at the bottom of that method to look like the following:


'status' => 'success',
    'page' => ASSession::get('prev_page', get_redirect_page())