mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
remove session when logging out
This commit is contained in:
parent
6a558a4d26
commit
9050f8b374
|
@ -258,7 +258,24 @@ class RestapiController { /* {{{ */
|
|||
$userobj = $this->container->userobj;
|
||||
$settings = $this->container->config;
|
||||
|
||||
setcookie("mydms_session", '', time()-3600, $settings->_httpRoot);
|
||||
if(isset($_COOKIE['mydms_session'])) {
|
||||
$dms_session = $_COOKIE["mydms_session"];
|
||||
$db = $dms->getDb();
|
||||
|
||||
$session = new SeedDMS_Session($db);
|
||||
$session->load($dms_session);
|
||||
|
||||
// If setting the user id to 0 worked, it would be a way to logout a
|
||||
// user. It doesn't work because of a foreign constraint in the database
|
||||
// won't allow it. So we keep on deleting the session and the cookie on
|
||||
// logout
|
||||
// $session->setUser(0); does not work because of foreign user constraint
|
||||
|
||||
if(!$session->delete($dms_session)) {
|
||||
UI::exitError(getMLText("logout"),$db->getErrorMsg());
|
||||
}
|
||||
setcookie("mydms_session", '', time()-3600, $settings->_httpRoot);
|
||||
}
|
||||
return $response->withJson(array('success'=>true, 'message'=>'', 'data'=>''), 200);
|
||||
} /* }}} */
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user