Welcome Guest, Not a member yet? Register   Sign In
CI Routing to default, when function is available
#1

[eluser]TimoTimo[/eluser]
Hi, I'm using code igniter for a website, I'm in the building process, and everything works brilliant...except the logout function.

I routed /uitloggen (logout in Dutch) to the login/logoff function.

Code:
$route['uitloggen'] = "login/logout";

The function looks like this:

Code:
function logout()
{    
$this->session->unset_userdata();
$this->session->sess_destroy();

$this->load->helper('url');
redirect('/home', 'location', 301);
}

Testing made clear, that the function is - sometimes - found, but most of the time, it will just redirect to the 'default_controller'.

CodeIgniter documentation showed me this:

Quote:This route indicates which controller class should be loaded if the URI contains no data, which will be the case when people load your root URL.

But obviously this isn't the case, so I hope someone can help me out here, the site where this is hosted is here: www.sollicitatievideoclip.nl
By the way: I was just messing with the session database check, so that's why you see the db query, but that didn't really change a thing.
And on another side note, is unsetting the userdata enough to log off a user? eg remove all data?

Thanks in advance,

Timo
#2

[eluser]InsiteFX[/eluser]
Code:
$this->session->unset_userdata();
$this->session->destroy();
#3

[eluser]TimoTimo[/eluser]
Thanks for your response, but unfortunately I already tried this command, without success.
#4

[eluser]InsiteFX[/eluser]
Then you something wrong with your code some place, because this
works for everone on here.

Check your code...

Or try:
Code:
$data = array()
$this->session->set_userdata($data);
$this->session->destroy();

Also I do not see why you are deleting the session in the session table CI automatically deletes them.
#5

[eluser]TimoTimo[/eluser]
Thanks for your response again, I will try to build a new function, and call that.

To ask your question about the db: I wasn't sure if it would go automatically, so I just tried it for testing.
I will also try the set_userdata thing.

Will keep you posted! Thanks

edit I now managed to get it to redirect to another page, the redirect is in the logout function, but now it's not unsetting the data..and when I put an exit() or die() statement in the function, it will just move on.. is there some cahcing system involved or something? (there is no other redriect to videos, except for the direct linked /videos)
#6

[eluser]InsiteFX[/eluser]
Code:
redirect('controller/method', 'refresh');
#7

[eluser]TimoTimo[/eluser]
Didn't help either, besides, the way the redirect is done now, is used in the whole application...

It is weird, because in the logs, I found this one time where it said that the uri did not contain any parameters, but now it just logs that it views the videos page, while it should load the logout method and the redriect to home...
#8

[eluser]johnnortredamme[/eluser]
Timo, I had the exact same problem yesterday. I got frustrated but then I found this thread and tried InsiteFX's instructions and I was able to solve it. Big thanks to you InsiteFX. Hope you can make it work Timo.




Theme © iAndrew 2016 - Forum software by © MyBB