Welcome Guest, Not a member yet? Register   Sign In
Redirection to the action i were before/actually
#1

[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?
#2

[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)));
#3

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




Theme © iAndrew 2016 - Forum software by © MyBB