Installation

With Composer

composer require atomastic/session

Usage

use Atomastic\Session\Session;

// Create the session object.
$session = new Session();

// Set session options.
$session->setOptions([
    'use_cookies' => 1,
    'cookie_secure' => 1,
    'use_only_cookies' => 1,
    'cookie_httponly' => 1,
    'use_strict_mode' => 1,
    'sid_bits_per_character' => 5,
    'sid_length' => 48,
    'cache_limiter' => 'nocache',
    'cookie_samesite' => 'Lax'
]);

// Start session.
$session->start();
Edit this page on GitHub

Getting Started

Methods

  • all Gets all session values as array.
  • close Force the session to be saved and closed. Session data is usually stored after your script terminated without the need to call close(), but as session data is locked to prevent concurrent writes only one script may operate on a session at any time. When using framesets together with sessions you will experience the frames loading one by one due to this locking. You can reduce the time needed to load all the frames by ending the session as soon as all changes to session variables are done.
  • delete Deletes an attribute by key.
  • destroy Deletes an attribute by key.
  • flush Flush all session data.
  • get Gets an attribute by key.
  • getCookieParams Get cookie parameters.
  • getId Returns the session ID.
  • getName Returns the session name.
  • getOptions Get session runtime configuration.
  • has Returns true if the key exists.
  • isStarted Checks if the session was started.
  • pull Gets an session attribute by key and remove it.
  • regenerateId Regenerates the session ID
  • set Sets an session attribute by key.
  • setCookieParams Set cookie parameters.
  • setId Sets the session ID.
  • setOptions Set session runtime configuration.
  • start Starts the session.