UserSession
in package
Administration session with user rights
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- delete() : void
- Unset session value
- get() : mixed|null
- Get session value
- getCustom() : array<string, mixed>|string|null
- Get module settings
- getId() : int|null
- Get logged user Id
- getMark() : string
- getModule() : array<string, mixed>|string|null
- Get module info
- getModuleId() : int|null
- Get module id
- getModuleList() : array<string, mixed>
- Get user module list
- getSettings() : array<string, mixed>|string|int|bool|null
- haveRights() : bool
- Get user right for selected module
- isCsrf() : bool
- Check CSRF, returns null on unset csrf
- isLogged() : bool
- Is user logged in
- login() : string
- Use crypt instead of hash, delay 2 sec on wrong login
- logout() : void
- User logout
- set() : void
- Set session value
- create() : void
- Create user session
- exists() : bool
- Check existence
- getIPs() : array<string|int, string>
- loadModules() : void
- Load user modules
- reLoad() : bool
- Check user login
- verifyAndUpdate() : bool
- Check password / optionally update old SHA1 password to BCRYPT
Properties
$db
protected
SQL
$db
$log
protected
Logger|null
$log
= null
$logged
protected
bool
$logged
= false
$modules
protected
array<string, array<string, mixed>>
$modules
= []
Methods
__construct()
public
__construct(SQL $db[, Logger|null $log = null ]) : mixed
Parameters
delete()
Unset session value
public
delete(string $mark) : void
Parameters
- $mark : string
get()
Get session value
public
get(string $mark) : mixed|null
Parameters
- $mark : string
Return values
mixed|nullgetCustom()
Get module settings
public
getCustom(string $file[, string|null $col = null ]) : array<string, mixed>|string|null
Parameters
- $file : string
- $col : string|null = null
Return values
array<string, mixed>|string|nullgetId()
Get logged user Id
public
getId() : int|null
Return values
int|nullgetMark()
public
getMark() : string
Return values
stringgetModule()
Get module info
public
getModule(string $file[, string|null $col = null ]) : array<string, mixed>|string|null
Parameters
- $file : string
- $col : string|null = null
Return values
array<string, mixed>|string|nullgetModuleId()
Get module id
public
getModuleId(string $file) : int|null
Parameters
- $file : string
Return values
int|nullgetModuleList()
Get user module list
public
getModuleList([array<string|int, string> $type = null ][, string|null $col = 'name' ]) : array<string, mixed>
Parameters
- $type : array<string|int, string> = null
- $col : string|null = 'name'
Return values
array<string, mixed>getSettings()
public
getSettings(string $mark) : array<string, mixed>|string|int|bool|null
Parameters
- $mark : string
Return values
array<string, mixed>|string|int|bool|nullhaveRights()
Get user right for selected module
public
haveRights(string $file, string $right) : bool
Parameters
- $file : string
- $right : string
Return values
boolisCsrf()
Check CSRF, returns null on unset csrf
public
isCsrf() : bool
Return values
boolisLogged()
Is user logged in
public
isLogged() : bool
Return values
boollogin()
Use crypt instead of hash, delay 2 sec on wrong login
public
login(string $login, string $password[, mixed|string $salt = '' ]) : string
Parameters
- $login : string
- $password : string
- $salt : mixed|string = ''
-
Deprecated !!!
Return values
stringlogout()
User logout
public
logout() : void
set()
Set session value
public
set(string $mark, mixed $value) : void
Parameters
- $mark : string
- $value : mixed
create()
Create user session
protected
create(int $id, string $name, string $hash, string $type, mixed $custom) : void
Parameters
- $id : int
- $name : string
- $hash : string
- $type : string
- $custom : mixed
exists()
Check existence
protected
exists([string $mark = 'USER' ]) : bool
Parameters
- $mark : string = 'USER'
Return values
boolgetIPs()
protected
getIPs() : array<string|int, string>
Return values
array<string|int, string>loadModules()
Load user modules
protected
loadModules() : void
reLoad()
Check user login
protected
reLoad() : bool
Return values
boolverifyAndUpdate()
Check password / optionally update old SHA1 password to BCRYPT
protected
verifyAndUpdate(string $password, string &$hash, array<string, string>|string $salt) : bool
Parameters
- $password : string
- $hash : string
- $salt : array<string, string>|string