]> git.mxchange.org Git - friendica.git/blob - src/Module/Security/Logout.php
clear cookie before session clear
[friendica.git] / src / Module / Security / Logout.php
1 <?php
2 /**
3  * @file src/Module/Logout.php
4  */
5
6 namespace Friendica\Module\Security;
7
8 use Friendica\BaseModule;
9 use Friendica\Core\Cache;
10 use Friendica\Core\Hook;
11 use Friendica\Core\L10n;
12 use Friendica\Core\Session;
13 use Friendica\Core\System;
14 use Friendica\DI;
15 use Friendica\Model\Profile;
16
17 /**
18  * Logout module
19  *
20  * @author Hypolite Petovan <hypolite@mrpetovan.com>
21  */
22 class Logout extends BaseModule
23 {
24         /**
25          * @brief Process logout requests
26          */
27         public static function init(array $parameters = [])
28         {
29                 $visitor_home = null;
30                 if (remote_user()) {
31                         $visitor_home = Profile::getMyURL();
32                         Cache::delete('zrlInit:' . $visitor_home);
33                 }
34
35                 Hook::callAll("logging_out");
36                 DI::cookie()->clear();
37                 Session::clear();
38
39                 if ($visitor_home) {
40                         System::externalRedirect($visitor_home);
41                 } else {
42                         info(L10n::t('Logged out.'));
43                         DI::baseUrl()->redirect();
44                 }
45         }
46 }