Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i have implement the php sdk for the facebook login in my project.. and all works with the login except the logout.

how can i write the code to call a function from the controller to destroy the session?

tried a lot of things but can´t get understand how can i do this..

hope that somebody can help me with this.

my model with the logouturl is this:

'logoutUrl' => $this->facebook->getLogoutUrl()

and the function in the controller is this:

public function logout()
{   
     $this->CI->session->sess_destroy('logourUrl');
     $this->load->view('home');
     // do more thing you want to do such as redirect
}
share|improve this question
    
any error given? what behaviour is expected? –  Kyslik Jun 9 '13 at 18:47
    
no... dont show any error –  user2232273 Jun 9 '13 at 19:47

1 Answer 1

up vote 1 down vote accepted

Try adding the below in your controller

 function logout()
        {   $logout = $this->facebook->getLogoutUrl(array('next'=>'url to be redirected after logout'));
            $this->facebook->destroySession();
            $this->session->sess_destroy();
            header("Location:$logout");
        }

You don't need to load the view because facebook will automatically redirect to the given url after logout.

share|improve this answer
    
i tried with your answer.. but when i click at the logout button, nothing happend.. any ideia what´s going on? –  user2232273 Jun 9 '13 at 19:06
    
what is the logout button url? are you calling the required function(ie logout)? What is happening? –  curious_coder Jun 10 '13 at 3:29
    
@courious_coder .. finally i solved my problem.. with the help from your code the –  user2232273 Jun 11 '13 at 8:59
    
@user2232273: Happy that it solved your problem. –  curious_coder Jun 11 '13 at 9:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.