PHP code example of mmdm / sim-session

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

    

mmdm / sim-session example snippets

 
composer 



// to instance a session object (without crypt)
$session = new Session();
// set a session
$session->set($key, $value);
// get a session
$theValue = $session->get($key);

// send crypt instance through session
// constructure (dependency injection)
$session = new Session($crypt);
// now your sessions are safe

// start PHP sessions
$session->start();
// regnerate session id
$session->start(true);

// close PHP session
$session->close();

// close PHP session
$session->hasStart();

// to set a session
$session->set('foo', 'I am a normal session');
// or
$session->set('foo.bar', 'I am a normal session');

// to get a session
$session->get('foo');
// or
$session->get('foo.bar', 'not set');

// to remove a session
$session->remove('foo');
// or
$session->remove('foo.bar');

// to check existence of a session
$session->has('foo');
// or
$session->has('foo.bar');

// to set a timer session
$session->setTimed('foo', 'I will expire after 10 seconds', 10);
// or
$session->setTimed('foo.bar');

// to set a timer session
$session->getTimed('foo');
// or
$session->getTimed('foo.bar', 'not set');

// to remove a timer session
$session->removeTimed('foo');
// or
$session->removeTimed('foo.bar');

// to check existence of a timer session
$session->hasTimed('foo');
// or
$session->hasTimed('foo.bar');

// to set a flash session
$session->setFlash('foo');
// or
$session->setFlash('foo.bar');

// to get a flash session
$session->getFlash('foo');
// or
$session->getFlash('foo.bar', 'not set');

// to remove a flash session
$session->removeFlash('foo');
// or
$session->removeFlash('foo.bar', 'not set');

// to check existence of a flash session
$session->hasFlash('foo');
// or
$session->hasFlash('foo.bar');