3 use Symfony\Component\HttpFoundation\Session\SessionInterface;
4 use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
5 use Symfony\Component\HttpFoundation\Session\Session;
57 $result = $this->storage->start();
69 public function migrate($destroy =
false) {
70 return $this->storage->migrate($destroy);
82 $this->storage->clear();
83 $this->logged_in_user =
null;
96 return $this->storage->isStarted();
106 return $this->storage->getId();
117 $this->storage->setId(
$id);
127 return $this->storage->getName();
138 $this->storage->setName(
$name);
171 return $this->storage->remove(
$name);
194 return $this->storage->has(
$name);
206 if ($current_user !=
$user) {
207 $this->
set(
'guid', $user->guid);
208 $this->logged_in_user =
$user;
261 $this->logged_in_user =
null;
262 $this->
remove(
'guid');
286 $this->ignore_access = $ignore;
332 if (!$this->
has(
'__elgg_session')) {
333 $this->
set(
'__elgg_session',
_elgg_services()->crypto->getRandomString(22));
379 if (in_array(
$key, array(
'user',
'id',
'name',
'username'))) {
381 if ($this->logged_in_user) {
387 return $this->logged_in_user->guid;
391 return $this->logged_in_user->$key;
400 return $this->
get(
$key);
405 if ($orig_value !==
$value) {
441 if (in_array(
$offset, array(
'user',
'id',
'name',
'username'))) {
464 $storage =
new MockArraySessionStorage();
if(! $collection_name) $id
if($guid==elgg_get_logged_in_user_guid()) $name
offsetUnset($key)
Unset a value from the cache and the session.
migrate($destroy=false)
Migrates the session to a new session id while maintaining session attributes.
offsetSet($key, $value)
Set a value, go straight to session.
has($name)
Has the attribute been defined.
static getMock()
Get an isolated ElggSession that does not persist between requests.
setLoggedInUser(\ElggUser $user)
Sets the logged in user.
invalidate()
Invalidates the session.
getLoggedInUser()
Gets the logged in user.
getIgnoreAccess()
Get current ignore access setting.
__construct(SessionInterface $storage)
Constructor.
isLoggedIn()
Returns whether or not the user is currently logged in.
__isset($key)
Test if property is set either as an attribute or metadata.
generateSessionToken()
Adds a token to the session.
offsetExists($offset)
Return whether the value is set in either the session or the cache.
getId()
Get the session ID.
del($key)
Alias to offsetUnset()
get_ignore_access()
Alias of getIgnoreAccess()
setId($id)
Set the session ID.
set_ignore_access($ignore=true)
Alias of setIgnoreAccess()
removeLoggedInUser()
Remove the logged in user.
setIgnoreAccess($ignore=true)
Set ignore access.
isStarted()
Has the session been started.
isAdminLoggedIn()
Returns whether or not the viewer is currently logged in and an admin user.
getLoggedInUserGuid()
Return the current logged in user by guid.
start()
Start the session.
getName()
Get the session name.
setName($name)
Set the session name.
offsetGet($key)
Get a variable from either the session, or if its not in the session attempt to get it from an api ca...
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.