The session class can be used to set, get, delete and to check if a session exists.
In this table you'll find information about the different methods you can use and what kind of data can be passed as an argument.
Method | Arg | Type | Expect |
---|---|---|---|
set() | 1 | string | session name |
set() | 2 | string | session value |
get() | 1 | string | session name |
exists() | 1 | string | session name |
delete() | 1 | string | session name |
The first argument should be the name of the session and the second argument the session value.
<?php
use core\Session;
Session::set('name', 'value');
To get a session value, call the get function method. The argument should be the session name.
<?php
use core\Session;
Session::get('name');
To check if a session exists, call the exists function method. The argument should be the session name.
<?php
use core\Session;
Session::exists('name');
To delete a session, call the delete function method. The argument should be the session name.
<?php
use core\Session;
Session::delete('name');