PHP code example of amitkhare / easy-session
1. Go to this page and download the library: Download amitkhare/easy-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/ */
amitkhare / easy-session example snippets
sh
// autoload via composer
e __DIR__.'/PATH-TO/EasySession.php';
// Take an instance of Session Class.
$sessionStoreName='MyCart';
$session = new AmitKhare\EasySession($sessionStoreName);
$key = 1;
$value = ['var1'=>123,'var2'=>'amit'];
// store item in $sessionStoreName
$session->set($key,$value);
// get item from $sessionStoreName by $key
$session->get($key);
// check if item exists in $sessionStoreName
$session->exists($key);
// all $sessionStoreName items
$session->all();
// remove specific item from $sessionStoreName
$session->remove($key);
// clear all items in $sessionStoreName
$session->clear();
// count items in $sessionStoreName
$session->count();