8 use Symfony\Component\HttpFoundation\Session\Session;
9 use Symfony\Component\HttpFoundation\Session\SessionInterface;
10 use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
11 use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
44 public function boot(): void {
49 $migrate_session =
false;
52 if ($this->
has(
'guid')) {
67 $migrate_session =
true;
73 $user->setLastAction();
76 if (
$user->isBanned()) {
102 if ($this->storage->getId()) {
106 $result = $this->storage->start();
107 $this->generateSessionToken();
118 public function migrate(
bool $destroy =
true) {
119 return $this->storage->migrate($destroy);
131 $this->storage->clear();
132 $result = $this->migrate(
true);
133 $this->generateSessionToken();
145 $this->storage->save();
155 return $this->storage->isStarted();
165 return $this->storage->getId();
176 $this->storage->setId(
$id);
186 return $this->storage->getName();
197 $this->storage->setName(
$name);
230 return $this->storage->remove(
$name);
241 return $this->storage->has(
$name);
254 if (!$this->has(
'__elgg_session')) {
255 $this->
set(
'__elgg_session',
_elgg_services()->crypto->getRandomString(22));
267 $storage =
new MockArraySessionStorage();
287 'cache_limiter' => session_cache_limiter(),
290 'cookie_path' =>
$params[
'path'],
291 'cookie_domain' =>
$params[
'domain'],
292 'cookie_secure' =>
$params[
'secure'],
293 'cookie_httponly' =>
$params[
'httponly'],
294 'cookie_lifetime' =>
$params[
'lifetime'],
295 'cookie_samesite' =>
$params[
'samesite'],
318 'cache_limiter' => session_cache_limiter(),
321 'cookie_path' =>
$params[
'path'],
322 'cookie_domain' =>
$params[
'domain'],
323 'cookie_secure' =>
$params[
'secure'],
324 'cookie_httponly' =>
$params[
'httponly'],
325 'cookie_lifetime' =>
$params[
'lifetime'],
328 $storage =
new NativeSessionStorage(
$options);
if(! $user||! $user->canDelete()) $name
$id
Generic annotation delete action.
$params
Saves global plugin settings.
$user
Elgg user account 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.
Throw when a Security Exception occurs.
if(count($css_vars)< 2) $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.
elgg_register_error_message(string|array $options)
Registers a error system message.
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)