Ubiquity
2.5.2
php rapid development framework
Loading...
Searching...
No Matches
SessionObject.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Ubiquity\utils\http\session
;
4
5
class
SessionObject
{
6
protected
$value
;
7
protected
$duration
;
8
protected
int
$creationTime
;
9
10
public
function
__construct
(
$value
,
$duration
) {
11
$this->value =
$value
;
12
$this->duration =
$duration
;
13
$this->creationTime = time ();
14
}
15
20
public
function
getValue
() {
21
if
(! $this->
isExpired
()) {
22
return
$this->value
;
23
}
24
return
;
25
}
26
31
public
function
getDuration
() {
32
return
$this->duration
;
33
}
34
39
public
function
getCreationTime
(): int {
40
return $this->creationTime;
41
}
42
48
public
function
setValue
($value) {
49
if
($value !== $this->value) {
50
$this->creationTime = time();
51
}
52
return
$this->value = $value;
53
}
54
59
public
function
setDuration
($duration) {
60
$this->duration = $duration;
61
}
62
67
public
function
isExpired
(): bool {
68
return \time () - $this->creationTime > $this->duration;
69
}
70
75
public
function
getTimeout
(): int {
76
$timeout = $this->duration - (\time () - $this->creationTime);
77
if
($timeout > 0) {
78
return
$timeout;
79
}
80
return
0;
81
}
82
}
83
Ubiquity\utils\http\session\SessionObject
Definition
SessionObject.php:5
Ubiquity\utils\http\session\SessionObject\$value
$value
Definition
SessionObject.php:6
Ubiquity\utils\http\session\SessionObject\$creationTime
int $creationTime
Definition
SessionObject.php:8
Ubiquity\utils\http\session\SessionObject\setDuration
setDuration($duration)
Definition
SessionObject.php:59
Ubiquity\utils\http\session\SessionObject\setValue
setValue($value)
Definition
SessionObject.php:48
Ubiquity\utils\http\session\SessionObject\getCreationTime
getCreationTime()
Definition
SessionObject.php:39
Ubiquity\utils\http\session\SessionObject\getDuration
getDuration()
Definition
SessionObject.php:31
Ubiquity\utils\http\session\SessionObject\getTimeout
getTimeout()
Definition
SessionObject.php:75
Ubiquity\utils\http\session\SessionObject\isExpired
isExpired()
Definition
SessionObject.php:67
Ubiquity\utils\http\session\SessionObject\getValue
getValue()
Definition
SessionObject.php:20
Ubiquity\utils\http\session\SessionObject\$duration
$duration
Definition
SessionObject.php:7
Ubiquity\utils\http\session\SessionObject\__construct
__construct($value, $duration)
Definition
SessionObject.php:10
Ubiquity\utils\http\session
Definition
AbstractSession.php:3
C:
Users
myadd
Documents
GitHub
ubiquity-doc-api
vendor
phpmv
ubiquity
src
Ubiquity
utils
http
session
SessionObject.php
Generated on Sun Dec 10 2023 15:04:27 for
Ubiquity
by
doxygen
1.9.8