Skip to content

Sessions

IvanCraft623 edited this page Jun 16, 2022 · 1 revision

Session Manager

Class that manage sessions

$sessionmanager = $ranksystem->getSessionManager();

Get a Session

Gets a session through its name.

$session = $sessionmanager->get("IvanCraft236");

Get all Sessions

Get all sessions loaded in cache.

$sessions = $sessionmanager->getAll();

Session

Class that contains the data and administrate a player

Session Initialization

Because the plugin works asynchronously, it is possible that the player's data has not been loaded at the time of obtaining the session. RankSystem starts loading the player's data during PreLogin, so it is likely that the data has already been loaded if the player has already conected.

In either case you can use the onInitialize function to be sure that what you want is executed once the session is initialized:

$session->onInitialize(function() {
	// do something...
});

Get Ranks

Get the ranks of the session.

$ranks = $session->getRanks();

Give a Rank

Give a rank to the session.

$session->setRank($rank);

Can you provide the time it will expire:

$session->setRank($rank, time() + 60); // rank will expire in a minute

Know if the session has a specific rank

You can provide a Rank or string argument.

if ($session->hasRank($rank)) {
	// do something...
}
// or
if ($session->hasRank("YouTuber")) {
	// do something...
}

Get Permissions

Get the permissions of the session.

$permissions = $session->getPermissions();

Give a Permission

Give a permission to the session.

$session->setPermission("example.perm");

Can you provide the time it will expire:

$session->setPermission("example.perm", time() + 60); // permission will expire in a minute

Know if the session has a specific permission

You should provide a string argument.

if ($session->hasPermission("example.perm")) {
	// do something...
}