CodeIgniter Forums
Login and going back to previous section - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Login and going back to previous section (/showthread.php?tid=50039)



Login and going back to previous section - El Forum - 03-12-2012

[eluser]bleu[/eluser]
I have my login section in my header. I want my user to login and go back to the page from which he logged in.

How can I achieve that?


Login and going back to previous section - El Forum - 03-12-2012

[eluser]PhilTem[/eluser]
It's pretty simply!

Add a hidden field to your login form which stores the URL of the current page. After validating the user's credentials, check for this post-field and simply redirect him.


Login and going back to previous section - El Forum - 03-12-2012

[eluser]porquero[/eluser]
I recommend use Flashdata in protected sections to storing uri, so when the user is logged correctly you can redirect recovery flash data.

See more:

http://ellislab.com/codeigniter/user-guide/libraries/sessions.html