PHP code example of lune / session
1. Go to this page and download the library: Download lune/session library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lune / session example snippets
//create a new Manager
$sessions = new \Lune\Session\Manager();
//add a value to the session
$sessions->get('my-session')->set('foo', 'bar');
//add multiple values to the session
$sessions->get('my-session')->set(['foo2' => 'bar2']);
//retrieve a value from the session
$v = $sessions->get('my-session')->get('foo'); // returns 'bar'
//use a default value if the key does not exist
$v = $sessions->get('my-session')->get('foo3', 'bar3'); // returns 'bar3'
//check if a key is defined in the session
$sessions->get('my-session')->has('foo'); // returns true
//clear a value
$sessions->get('my-session')->remove('foo');
//clear multiple values
$sessions->get('my-session')->remove(['foo', 'foo2']);
//clear all values for a specific session
$sessions->get('my-session')->clear();