CodeIgniter Forums
Redirection to the action i were before/actually - 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: Redirection to the action i were before/actually (/showthread.php?tid=9501)



Redirection to the action i were before/actually - El Forum - 06-27-2008

[eluser]kevinh21[/eluser]
Hi everyone,
Following situation:
I have 2 controllers: blog and user(it's the redux authentification library/controller).

I have the following layout that is built in the blog controller:
----------------
|--|--------|--|
|--|-content|--|
|--|--------|--|
----------------

In the right navigation i have the usercontrol panel (login/logout link and things like this).
The logout link refers to the "user/logout" function listed here:

Code:
function logout ()
{
    $this->redux_auth->logout(); // Destroy the session variables.
    redirect('');
}

With the redirect command it will show me the mainpage (controller: blog/index())
even if i was in the blog/viewpost action before.

What i want:
If i'm looking a blogpost and click the logout link on the right side, it should log me out (user/logout()) but then it should redirect me to the page i was before -> viewing a post in this situation (blog/viewpost())

How is this possible?


Redirection to the action i were before/actually - El Forum - 06-27-2008

[eluser]Seppo[/eluser]
You can use $this->input->server('HTTP_REFERER'); to fetch the page where the user come from

Or you can pass it in every link you generate...
Code:
echo anchor('login/logout/' . $this->uri->uri_string());

Code:
redirect(implode('/', array_slice($this->uri->segment_array(), 2)));



Redirection to the action i were before/actually - El Forum - 06-27-2008

[eluser]kevinh21[/eluser]
You are genius..thanks so much!