Session

Description

This class can manage PHP session`s assigned with a name. It can take assign the name of the current session to a given name. The class also provides functions to provide features of interest like:

  • Assign a fingerprint value based on the current session name, user IP address and browser
  • Check if the current session fingerprint is still values
  • Set, get, check and delete one session variable
  • Set, get, check and delete multiple session variables at once

This is a simple framework element, allowing for quick session operations in php. One-line defining of a global variable.

Instead of checking whether it exists in one line, we receive those two things.

$this->baseClass->session->get('ok', false);

In this case, we download $_SESSION['ok'] and if it doesn't exist right away, we define it with the second parameter false. You can put any value in place of false.

Assigning to $this->baseClass->session is found in the app/bootstrap.php file, as $this->session = new \Dframe\Session('name');. Parameter is relayed to the object and defines the session name.


Standalone

Simplicity and minimalism make you want to use the same class. In order to achieve that, the following methods are available in the project.

$this->session = new \Dframe\Session('name');
$session = new Session('HashSaltRandomForSession');
$session->register(); // Set session_id and session_time - default 60
$session->authLogin(); // Return true/false if session is registrer
$session->set($key, $value); // set $_SESSION[$key] = $value;
$session->get($key, $or = null); // get $_SESSION[$key];
$session->remove($key) // unset($_SESSION[$key]);
$session->end(); // session_destroy
Edit page (Session/overview)