Auth system knowing where you come from |
[eluser]Kurai[/eluser]
Hi there! In the app I building I have an authorization system which I built from scratch. Basically, when I come to a page which needs login, it checks if there's an open session. If so, it just send you to the auth system for the login. Now, here's the problem (maybe stupid, but I'm a bit of a newbie here): at first, I've got only a landing page. Now, I would like the system to remember the exact page which sent the user to the auth routine, so it can send him back exactly to the page where he came from. How can I do it? Thank you!
[eluser]wiredesignz[/eluser]
routes.php Code: //login/:any routed to login->index($any) auth check library Code: //auth check failed so send user to login controller with this uri attached login controller Code: //get the return path from the uri
[eluser]Kurai[/eluser]
It doesn't work. there must be some kind of error when I redirect, because the uri string is obviously correct, but it keeps me bouncing back to the home page. From what I see, it seems not to recognize the $redir in the redirect function. If I do something like: redirect ($redir . "something"); it sees just the "something part. Strange. Code: function login()
[eluser]adamp1[/eluser]
This is rather simple to do. All you need to use is flashSessions. When you check a user has permission to access a page, if they don't you store the $this->uri->uri_string() into a flashSession variable. Then when you show the login form you must stop it getting deleted (since it only lasts 1 page load). Then when you verify there login details you send them to the value stored in the flash variable. So something along the lines of: Check the user has access: Code: function check() Display Login Form: Code: function login_form() Log user in function: Code: function _login() There you go, that's how I do it.
[eluser]wiredesignz[/eluser]
This is wrong also: Code: //not segments
[eluser]erik.brannstrom[/eluser]
I have found this thread immensely useful: [library] History. Check it out! |
Welcome Guest, Not a member yet? Register Sign In |