Login/Register for checkout page?
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 开发者_如何学Pythoncreated 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
header("location: /login");
some data to the session like:
$_SESSION['redirectAfterLogin'] = '/account';
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).
精彩评论