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')) {
66 $migrate_session =
true;
72 $user->setLastAction();
75 if (
$user->isBanned()) {
101 if ($this->storage->getId()) {
105 $result = $this->storage->start();
106 $this->generateSessionToken();
117 public function migrate(
bool $destroy =
true) {
118 return $this->storage->migrate($destroy);
130 $this->storage->clear();
131 $result = $this->migrate(
true);
132 $this->generateSessionToken();
144 $this->storage->save();
154 return $this->storage->isStarted();
164 return $this->storage->getId();
175 $this->storage->setId(
$id);
185 return $this->storage->getName();
196 $this->storage->setName(
$name);
229 return $this->storage->remove(
$name);
240 return $this->storage->has(
$name);
253 if (!$this->has(
'__elgg_session')) {
254 $this->
set(
'__elgg_session',
_elgg_services()->crypto->getRandomString(22));
266 $storage =
new MockArraySessionStorage();
286 'cache_limiter' => session_cache_limiter(),
289 'cookie_path' =>
$params[
'path'],
290 'cookie_domain' =>
$params[
'domain'],
291 'cookie_secure' =>
$params[
'secure'],
292 'cookie_httponly' =>
$params[
'httponly'],
293 'cookie_lifetime' =>
$params[
'lifetime'],
294 'cookie_samesite' =>
$params[
'samesite'],
317 'cache_limiter' => session_cache_limiter(),
320 'cookie_path' =>
$params[
'path'],
321 'cookie_domain' =>
$params[
'domain'],
322 'cookie_secure' =>
$params[
'secure'],
323 'cookie_httponly' =>
$params[
'httponly'],
324 'cookie_lifetime' =>
$params[
'lifetime'],
327 $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.
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)