-
Notifications
You must be signed in to change notification settings - Fork 69
/
UserSessionEntity.php
210 lines (188 loc) · 5.06 KB
/
UserSessionEntity.php
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
/*
* This file is part of the Zikula package.
*
* Copyright Zikula Foundation - http://zikula.org/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Zikula\UsersModule\Entity;
use Doctrine\ORM\Mapping as ORM;
use Zikula\Core\Doctrine\EntityAccess;
/**
* UserSession entity class.
*
* @ORM\Entity(repositoryClass="Zikula\UsersModule\Entity\Repository\UserSessionRepository")
* @ORM\Table(name="session_info")
*
* Sessions Table.
* Stores per-user session information for users who are logged in.
* (Note: Users who use the "remember me" option when logging in remain logged in across multiple visits for a defined period of time, therefore their session record remains active.)
*/
class UserSessionEntity extends EntityAccess
{
/**
* Session ID: Primary identifier
*
* @ORM\Id
* @ORM\Column(type="string", length=60)
* @ORM\GeneratedValue(strategy="NONE")
*/
private $sessid;
/**
* IP Address: The user's IP address for the session.
*
* @ORM\Column(type="string", length=40)
*/
private $ipaddr;
/**
* Last Used Date/Time: Date/time this session record was last used for the user.
* NOTE: This is stored as an SQL datetime, which is highly dependent on both PHP's timezone setting, and on the database server's timezone setting. If they do not match, then inconsistencies will propogate.
* If Zikula is moved to a new database server with a different time zone configuration, then these dates/times will be interpreted based on the new time zone, not the original one!
*
* @ORM\Column(type="datetime")
*/
private $lastused;
/**
* User ID: Primary ID of the user record to which this session record is related. Foreign key to users table.
*
* @ORM\Column(type="integer")
*/
private $uid;
/**
* Remember Me?: Whether the last successful login by the user (which creted this session record) used the "remember me" option to remain logged in between visits.
*
* @ORM\Column(type="smallint")
*/
private $remember;
/**
* Session Variables: Per-user/per-session variables. (Serialized)
*
* @ORM\Column(type="text")
*/
private $vars;
/**
* constructor
*/
public function __construct()
{
$this->sessid = '';
$this->ipaddr = '';
$this->lastused = new \DateTime("now");
$this->uid = 0;
$this->remember = 0;
$this->vars = '';
}
/**
* get the session id of the user session
*
* @return string the user session's session id
*/
public function getSessid()
{
return $this->sessid;
}
/**
* set the session id for the user session
*
* @param string $sessid the user session's session id
*/
public function setSessid($sessid)
{
$this->sessid = $sessid;
}
/**
* get the ip address of the user session
*
* @return string the user session's ip address
*/
public function getIpaddr()
{
return $this->ipaddr;
}
/**
* set the ip address for the user session
*
* @param string $ipaddr the user session's ip address
*/
public function setIpaddr($ipaddr)
{
$this->ipaddr = $ipaddr;
}
/**
* get the last used datetime of the user session
*
* @return \DateTime the user session's last used datetime
*/
public function getLastused()
{
return $this->lastused;
}
/**
* set the last used datetime for the user session
*
* @param string|\DateTime $lastused the user session's last used datetime
*/
public function setLastused($lastused)
{
if (!($lastused instanceof \DateTime)) {
$lastused = new \DateTime($lastused);
}
$this->lastused = $lastused;
}
/**
* get the uid of the user session
*
* @return integer the user session's uid
*/
public function getUid()
{
return $this->uid;
}
/**
* set the uid for the user session
*
* @param integer $uid the user session's uid
*/
public function setUid($uid)
{
$this->uid = $uid;
}
/**
* get the remember status of the user session
*
* @return integer the user session's remember status
*/
public function getRemember()
{
return $this->remember;
}
/**
* set the remember status for the user session
*
* @param integer $remember the user session's remember status
*/
public function setRemember($remember)
{
$this->remember = $remember;
}
/**
* get the vars of the user session
*
* @return string the user session's vars
*/
public function getVars()
{
return $this->vars;
}
/**
* set the vars for the user session
*
* @param string $vars the user session's vars
*/
public function setVars($vars)
{
$this->vars = $vars;
}
}