Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
SessionTokenStorage.php
Go to the documentation of this file.
1<?php
3
5
7
8 protected $key = '_CSRF';
9
10 protected function getKey($id) {
11 return $this->key . '/' . $id;
12 }
13
14 public function __construct(string $key = '_CSRF') {
15 $this->key = $key;
16 }
17
18 public function set(string $id, string $token): void {
19 USession::set($this->getKey($id), $token);
20 }
21
22 public function get(string $id): ?string {
23 return USession::get($this->getKey($id));
24 }
25
26 public function exists(string $id): bool {
27 return USession::exists($this->getKey($id));
28 }
29
30 public function remove(string $id): ?string {
31 $v = USession::get($id);
32 USession::delete($this->getKey($id));
33 return $v;
34 }
35}
36
exists(string $id)
Checks whether a token with the given token ID exists.
set(string $id, string $token)
Stores a CSRF token.
Http Session utilities This class is part of Ubiquity.
Definition USession.php:16