Welcome Guest, Not a member yet? Register   Sign In
Help on logout on CI 2.0.2
#1

[eluser]spaquet[/eluser]
Here is the logout function:
Code:
public function logout() {
        $this->session->sess_destroy();
        redirect('/');
    }

First: I'm getting the following error
Quote:Message: Undefined property: Logout::$session
which is pretty strange since session is loaded and running properly on the login page and main pages of the site...

Second: when I'm just doing a session data cleanup the following way:
Code:
$this->_remove_session($this->session->all_userdata());
redirection is not happening. I'm getting a white page with no code in while I want it to be the home page (in my cas the login form)..
I tried
Quote:redirect('login/index')
but this did not change anything...
#2

[eluser]Atharva[/eluser]
Quote:Message: Undefined property: Logout::$session

Are you sure you are loading session library globally? (In autoload)
#3

[eluser]spaquet[/eluser]
[quote author="Atharva" date="1305839984"]
Quote:Message: Undefined property: Logout::$session

Are you sure you are loading session library globally? (In autoload)[/quote]

100% sure.
Here is the line in the autoload.php file of this project:
Code:
$autoload['libraries'] = array('database', 'session', 'form_validation');
I also added (but now removed it since redundant)
Code:
$this->load->library('session');
in my controller and it changes nothing at all.
#4

[eluser]cideveloper[/eluser]
Where is the function logout located. Is it in the controller? what is the name of the controller? is the controller extending CI_Controller?
#5

[eluser]spaquet[/eluser]
Yes the controller is extending CI_controller and the name of the controller is not a reserved word.

And yes the function is located in the controller. I have an ancho in the view pointing at it. Everything is working fine, but when called there is first the error message regarding the session object and when I'm deleting one by one each user session object I'm redirected to a blank page...
#6

[eluser]InsiteFX[/eluser]
If your logout method is in a library then you need to use the CI Super Object to access it!
Code:
public function logout()
{
    $ci = get_instance();

    $CI->session->sess_destroy();
    redirect('/');
}

class something {

    private $CI;

    public function __construct()
    {
        $this->CI = get_instance();
    }
}

InsiteFX
#7

[eluser]Atharva[/eluser]
spammers :coolmad:
#8

[eluser]spaquet[/eluser]
Will give a try to your suggestion and keep you updated.

Regarding the second point, it looks like at some point in the code autload is not working as expected and that some libraries or helpers are not properly seen.

I found out a point (discussed in the forum and usually solved by adding 'url' in autoload) but not my issue: url is properly called but the redirect() method is said not declared (looking at my apache log files).
#9

[eluser]William Rufino[/eluser]
Autoload is not working, on the 404 override object sometimes, you CI unset() the CI object and creates the instance of the 404 override method.... it doesnt load again!
#10

[eluser]spaquet[/eluser]
No, does not solved the issue




Theme © iAndrew 2016 - Forum software by © MyBB