PHP code example of drmvc / session

1. Go to this page and download the library: Download drmvc/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/ */

    

drmvc / session example snippets



DrMVC\Session;

// Create session object, you can also set prefix
// as first argument of Session class
$session = new Session();

// Init session object
$session->init();

// Get ID of current session
$session_id = $session->id();

// Set few keys in session
$session
    ->set('text', 'value')
    ->set('integer', 123)
    ->set('boolean', true)
    ->set('array', ['mama', 'ama', 'criminal']);

// Receive variables of current session
$keys = $session->display();
var_dump($keys);

// Get some single value by key
$value = $session->get('integer');
var_dump($value);