Welcome Guest, Not a member yet? Register   Sign In
Get back to original URL after redirection to login
#1

[eluser]frist44[/eluser]
I have an application where certain pages require the user to be logged in. Let's say that page is named "submit".

If I'm at the home page, and a user clicks to go to "submit", i have a function that checks if they're logged in, and if not redirects to the login page.

What is a good way to get them to go to the "submit" page after successfully logging in?

Thanks!
#2

[eluser]rogierb[/eluser]
I have used flashdata (see sessions) but have swiched to 'normal' sessions since flashdata is gone after a second server request. That second or third or whatever server request is triggered after login failure.

Another way is to store the url or part of it in a cookie.
#3

[eluser]frist44[/eluser]
I'm using sessions. I realize this is probably the best way to use it, but I'm having difficulty getting the values to be accurate.

I tried putting a "prev_url" key in my session and have a hook write it out post controller, so any processing i do after a POST will accurately have the previous URL, but since I land on the login page, once there, prev_url would be the actual login page.

I also have a current_url session key, and I tried writing that to the prev_url key in MY_Controller, but that obviously gets overwritten before any processing is done because of the constructor.

any ideas?




Theme © iAndrew 2016 - Forum software by © MyBB