Elgg  Version 6.1
sessions.php
Go to the documentation of this file.
1 <?php
8 
16  return _elgg_services()->session;
17 }
18 
25  return _elgg_services()->session_manager->getLoggedInUser();
26 }
27 
35  return _elgg_services()->session_manager->getLoggedInUserGuid();
36 }
37 
43 function elgg_is_logged_in(): bool {
44  return _elgg_services()->session_manager->isLoggedIn();
45 }
46 
52 function elgg_is_admin_logged_in(): bool {
53  return _elgg_services()->session_manager->isAdminLoggedIn();
54 }
55 
65 function elgg_set_cookie(\ElggCookie $cookie): bool {
66  return _elgg_services()->responseFactory->setCookie($cookie);
67 }
68 
81 function elgg_login(\ElggUser $user, bool $persistent = false): void {
82  _elgg_services()->session_manager->login($user, $persistent);
83 }
84 
91 function elgg_logout(): bool {
92  return _elgg_services()->session_manager->logout();
93 }
94 
104  _elgg_services()->accounts->registerAuthenticationFailure($user);
105 }
106 
116  _elgg_services()->accounts->resetAuthenticationFailures($user);
117 }
118 
129 function elgg_is_authentication_failure_limit_reached(\ElggUser $user, int $limit = null, int $lifetime = null): bool {
130  return _elgg_services()->accounts->isAuthenticationFailureLimitReached($user, $limit, $lifetime);
131 }
132 
142  $session = _elgg_services()->session;
143  if ($session->has('last_forward_from')) {
144  $forward_url = $session->get('last_forward_from');
145  $session->remove('last_forward_from');
146  $forward_source = 'last_forward_from';
147  } elseif (get_input('returntoreferer')) {
149  $forward_source = 'return_to_referer';
150  } else {
151  // forward to main index page
152  $forward_url = '';
153  $forward_source = null;
154  }
155 
156  $params = [
157  'user' => $user,
158  'source' => $forward_source,
159  ];
160 
161  return elgg_trigger_event_results('login:forward', 'user', $params, $forward_url);
162 }
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:43
$params
Saves global plugin settings.
Definition: save.php:13
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:52
elgg_get_session()
Gets Elgg&#39;s session object.
Definition: sessions.php:15
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
elgg_register_authentication_failure(\ElggUser $user)
Registers an authentication failure for a user.
Definition: sessions.php:103
elgg_trigger_event_results(string $event, string $type, array $params=[], $returnvalue=null)
Triggers an event where it is expected that the mixed return value could be manipulated by event call...
Definition: events.php:117
elgg_logout()
Log the current user out.
Definition: sessions.php:91
elgg_reset_authentication_failures(\ElggUser $user)
Clears all authentication failures for a give user.
Definition: sessions.php:115
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
Definition: item.php:48
Elgg Session Management.
Definition: ElggSession.php:19
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
const REFERRER
Used in calls to forward() to specify the browser should be redirected to the referring page...
Definition: constants.php:37
$limit
Definition: pagination.php:28
$user
Definition: ban.php:7
if(!$entity->delete(true, true)) $forward_url
Definition: delete.php:30
elgg_get_login_forward_url(\ElggUser $user)
Determine which URL the user should be forwarded to upon successful login.
Definition: sessions.php:141
elgg_is_authentication_failure_limit_reached(\ElggUser $user, int $limit=null, int $lifetime=null)
Checks if the authentication failure limit has been reached.
Definition: sessions.php:129
elgg_set_cookie(\ElggCookie $cookie)
Set a cookie, but allow plugins to customize it first.
Definition: sessions.php:65
if(isset($_COOKIE['elggperm'])) $session
Definition: login_as.php:29
elgg_login(\ElggUser $user, bool $persistent=false)
Log in a user.
Definition: sessions.php:81
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353
$persistent
Definition: login_as.php:21
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:24
Login as the specified user.
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Definition: sessions.php:34