so I’m using the Facebook PHP SDK for authenticating my user….
and I’m trying to logout my user using the destroySession() method in base_facebook.php
These are some relevant excerpts in the PHP SDK’s base_facebook.php: https://github.com/facebook/php-sdk/blob/master/src/base_facebook.php
public function destroySession() {
$this->setAccessToken(null);
$this->user = 0;
$this->clearAllPersistentData();
}
protected function clearAllPersistentData() {
foreach (self::$kSupportedKeys as $key) {
$this->clearPersistentData($key);
}
}
protected function clearPersistentData($key) {
if (!in_array($key, self::$kSupportedKeys)) {
self::errorLog('Unsupported key passed to clearPersistentData.');
return;
}
$session_var_name = $this->constructSessionVariableName($key);
unset($_SESSION[$session_var_name]);
}
but everytime I try to do so, Zend Framework would complain
Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'session has already been started by session.auto-start or session_start()'
Zend_Session_Exception: session has already been started by session.auto-start or session_start()
How do I go about clearing my facebook session without triggering all these errors?
The prerequisite for using Zend_Session is the session must not be initiated yet. Facebook initiates it. As a solution, call session_write_close() before using Zend_Session.
Alternatively, call session_destroy() to logout the facebook user. It destroys all of the data associated with the current session.