Christian
Christian

Reputation: 329

codeigniter - Page with multiple forms

I'm new to codeigniter this is my case: I have a homepage with a list of items, I can navigate through pagination, but I have in my sidebar a login form, it's possible to return to the same page after try to login in the case that is valid or not with a validation message. for the login option I have a controller and login function but I don't know what view load after validation. I need to login in any controller and return to the same url. thanks

Upvotes: 1

Views: 1306

Answers (1)

Dolph
Dolph

Reputation: 50660

All your login forms should post to the same Login controller, which can then redirect the user back to the referring URL.

My personal approach is to remember the last "memorable" page (i.e. worth remembering) the user visited as a session variable. For example, I remember that the user visited the home/contact/products pages, but not the login/signup/404/tos/privacy/etc pages. After a successful login, the Login controller can redirect the user to the last memorable URL.

Upvotes: 1

Related Questions