File: LightManager.php Lines 28 to 73
28        }
29        $this->tokenStrategy = $strategy;
30    }
31
32    /**
33     * トークンを作る。
34     *
35     * @return string
36     */
Type Class Description
pmd Superglobals createToken accesses the super-global variable $_SESSION.
37
Type Class Description
pmd Superglobals createToken accesses the super-global variable $_SESSION.
    public function createToken() {
38        $token = $this->tokenStrategy->createToken();
39        $_SESSION[$this->sessionKey] = $token;
40        return $token;
41    }
42
Type Class Description
pmd Superglobals getToken accesses the super-global variable $_SESSION.
43
Type Class Description
pmd Superglobals getToken accesses the super-global variable $_SESSION.
    public function getToken() {
44        if(!$this->hasToken()) {
45            $this->createToken();
46        }
47        return $_SESSION[$this->sessionKey];
48    }
49
Type Class Description
pmd Superglobals checkToken accesses the super-global variable $_SESSION.
50
Type Class Description
pmd Superglobals checkToken accesses the super-global variable $_SESSION.
    public function checkToken($token) {
51        if($this->hasToken() && $token === $_SESSION['_csrf']) {
52            return true;
53        }
54        return false;
55    }
56
Type Class Description
pmd Superglobals hasToken accesses the super-global variable $_SESSION.
57
Type Class Description
pmd Superglobals hasToken accesses the super-global variable $_SESSION.
    public function hasToken() {
58        if(isset($_SESSION[$this->sessionKey])) {
59            return true;
60        }
61        return false;
62    }
Type Class Description
pmd Superglobals removeToken accesses the super-global variable $_SESSION.
63
Type Class Description
pmd Superglobals removeToken accesses the super-global variable $_SESSION.
    public function removeToken() {
64        unset($_SESSION[$this->sessionKey]);
65    }
66
67    /**
68     * トークンの保存先である $_SESSION のkeyを指定する
69     *
70     * 複数のトークンを扱う場合に有用。
71     * 初期値は '_csrf'
72     * @param string $sessionKey
73     */