7 use Symfony\Component\HttpFoundation\Session\Session;
8 use Symfony\Component\HttpFoundation\Session\SessionInterface;
9 use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
10 use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
44 public function boot(): void {
50 $migrate_session =
false;
53 if ($this->
has(
'guid')) {
67 $migrate_session =
true;
73 $user->setLastAction();
76 if (
$user->isBanned()) {
93 if ($this->storage->getId()) {
97 $result = $this->storage->start();
98 $this->generateSessionToken();
109 public function migrate(
bool $destroy =
true) {
110 return $this->storage->migrate($destroy);
122 $this->storage->clear();
123 $result = $this->migrate(
true);
124 $this->generateSessionToken();
136 $this->storage->save();
146 return $this->storage->isStarted();
156 return $this->storage->getId();
167 $this->storage->setId(
$id);
177 return $this->storage->getName();
188 $this->storage->setName(
$name);
221 return $this->storage->remove(
$name);
232 return $this->storage->has(
$name);
245 if (!$this->has(
'__elgg_session')) {
246 $this->
set(
'__elgg_session',
_elgg_services()->crypto->getRandomString(22));
258 $storage =
new MockArraySessionStorage();
278 'cache_limiter' => session_cache_limiter(),
281 'cookie_path' =>
$params[
'path'],
282 'cookie_domain' =>
$params[
'domain'],
283 'cookie_secure' =>
$params[
'secure'],
284 'cookie_httponly' =>
$params[
'httponly'],
285 'cookie_lifetime' =>
$params[
'lifetime'],
286 'cookie_samesite' =>
$params[
'samesite'],
309 'cache_limiter' => session_cache_limiter(),
312 'cookie_path' =>
$params[
'path'],
313 'cookie_domain' =>
$params[
'domain'],
314 'cookie_secure' =>
$params[
'secure'],
315 'cookie_httponly' =>
$params[
'httponly'],
316 'cookie_lifetime' =>
$params[
'lifetime'],
319 $storage =
new NativeSessionStorage(
$options);
if(! $user||! $user->canDelete()) $name
$id
Generic annotation delete action.
$params
Saves global plugin settings.
has($name)
Has the attribute been defined.
static getMock()
Get an isolated ElggSession that does not persist between requests.
invalidate()
Invalidates the session.
save()
Save the session data and closes the session.
__construct(SessionInterface $storage)
Constructor.
migrate(bool $destroy=true)
Migrates the session to a new session id while maintaining session attributes.
boot()
Initializes the session and checks for the remember me cookie.
generateSessionToken()
Adds a token to the session.
static fromFiles(Config $config)
Create a session stored in files.
static fromDatabase(Config $config, Database $db)
Create a session stored in the DB.
setId($id)
Set the session ID.
isStarted()
Has the session been started.
getID()
Get the session ID.
start()
Start the session.
getName()
Get the session name.
setName($name)
Set the session name.
Database session handler.
if($who_can_change_language==='nobody') elseif($who_can_change_language==='admin_only' &&!elgg_is_admin_logged_in()) $options
$config
Advanced site settings, debugging section.
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
_elgg_services()
Get the global service provider.
if(isset($_COOKIE['elggperm'])) $session
endTimer(array $keys)
Ends the timer (when enabled)
trait Profilable
Make an object accept a timer.
beginTimer(array $keys)
Start the timer (when enabled)