Assume user adding some products (via Add button), and then click on the checkout button.
If user have not logged in, it will redirect to a /login page.
After logged, how to redirect back to the checkout page?
by default, when user have logged in – it will redirect to a /account page.
I have created my own login authentication class.
checkout page, sample code:
if ($this->memberID) {
//show checkout page
} else {
header("location: /login");
}
Note: I use jquery ajax (to php) to check login detail
You can add before
some data to the session like:
And in Login controller after successed login, check if
$_SESSION['redirectAfterLogin']is not empty and then just redirect to the specified url (also remember to erase that value after you use it).