$Session
- is system object, that is responsible for current user session, instance can be obtained in such way:
<?php
$Session = \cs\Session::instance();
$Session
object has next public methods:
- admin()
- user()
- guest()
- get_id()
- get_user()
- get()
- load()
- add()
- del()
- del_all_sessions()
- get_data()
- set_data()
- del_data()
- is_session_owner()
Is admin
Is user
Is guest
Returns id of current session
Returns user id of current session
Returns session details by session id
Load session by id and return id of session owner (user), update session expiration
Create the session for the user with specified id
Destroying of the session
Deletion of all user sessions
Get data, stored with session
Store data with session
Delete data, stored with session
is_session_owner($session_id : string, $user_agent : string, $remote_addr : string, $ip : string) : bool
Whether session data belongs to current visitor (user agent, remote addr and ip check)
###[Up](#) Events$Session
object supports next events:
- System/Session/init/before
- System/Session/init/before
- System/Session/load
- System/Session/add
- System/Session/del_session/before
- System/Session/del_session/after
- System/Session/del_all_sessions
Is fired before initialization of user session (at object creation)
Is fired after initialization of user session (at object creation)
Event is fired during session loading
[
'session_data' => $session_data
]
Event is fired during session addition
[
'session_data' => $session_data
]
Event is fired before session deletion
[
'id' => session_id
]
Event is fired after session deletion
[
'id' => session_id
]
Event is fired before deleting of all sessions. Parameters array:
[
'id' => user_id
]