-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogout.php
More file actions
58 lines (50 loc) · 1.15 KB
/
Logout.php
File metadata and controls
58 lines (50 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2017/11/2 0002
* Time: 10:59
*/
require_once './Base.php';
class Logout extends Base
{
public function handle()
{
$this->deleteShareSession();
$this->deleterRememberKey();
$this->invaliateCookie();
session_destroy();
$this->logoutSucceed();
}
/**
* 删除共享session
*/
public function deleteShareSession()
{
if(is_null($_SESSION['user']['id'])) return;
$key = $this->getShareSessionKey($_SESSION['user']['id']);
$this->redis->del($key);
}
/**
* 删除rememberme 的数据
*/
public function deleterRememberKey()
{
if(isset($_COOKIE[$this->rememberKey]))
$this->redis->del($_COOKIE[$this->rememberKey]);
}
/**
*使cookie无效
*/
public function invaliateCookie()
{
setcookie(session_name(),'',time()-3600);
setcookie($this->rememberKey,'',time()-3600);
}
public function logoutSucceed()
{
$this->jsonReturn(stdOutPut([],'logout sussessfully',1));
}
}
$obj = new Logout();
$obj->handle();