Welcome Guest, Not a member yet? Register   Sign In
User login flow
#1

[eluser]adx1[/eluser]
Hey everyone,

So I'm relatively new to CI and to using MVC in web development. I'm trying to set up user logins and can't get quite the functionality I want.

I have a header view that's going to be included for every page on the site. Part of the header is a login form.

On my old site, the login form would always send the user to the page they were currently on (action="."). The code for handling the login was in the header file. So there wouldn't be any redirection on un/successful logins, they would remain at the page they were on, accordingly modified depending on the whether or not they successfully logged in.

I'm basically trying to get the same behavior now, but I'm not quite sure how to set it up. Any suggestions?

Thanks!
#2

[eluser]Colin Williams[/eluser]
Leave that workflow in the past. The beauty of MVC is getting your logic in, well, logical places. No more user authentication happening in your header file.

You will likely have a Session or User controller that processes the form. So, you no longer have an empty action attribute (not because of MVC, just because of CI's routing conventions). If you want the user to end up on the same page, pass the current url via the action attribute (action="session/login/path/to/go/to") or hidden form field; Then, redirect them with this value.




Theme © iAndrew 2016 - Forum software by © MyBB