PHP code example of kecik / session

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

    

kecik / session example snippets



 = new Kecik\Kecik();
$session = new Kecik\Session($app);


 = new Kecik\Kecik();

//Config untuk enkripsi session
$app->config->set('session.encrypt', TRUE);
$session = new Kecik\Session($app);


 = new Kecik\Kecik();
$session = new Kecik\Session($app);
echo $session->id();


 = new Kecik\Kecik();
$session = new Kecik\Session($app);
echo 'ID SESSION: '.$session->id().'<br />';
echo 'NEW ID SESSION: '.$session->newId().'<br />';

set(string $name, mixed $value)


 = new Kecik\Kecik();
$session = new Kecik\Session($app);
$session->set('integer', 123);
$session->set('string', 'satu dua tiga');
$session->set('array', array('satu', 'dua', 'tiga'));

get(string $name)


 = new Kecik\Kecik();
$session = new Kecik\Session($app);
$session->set('integer', 123);
$session->set('string', 'satu dua tiga');
$session->set('array', array('satu', 'dua', 'tiga'));

echo 'session Integer: '.$session->get('integer').'<br />';
echo 'session String: '.$session->get('string').'<br />';
echo 'Session Array: ';
print_r($session->get('array'));

delete(string $name)


 = new Kecik\Kecik();
$session = new Kecik\Session($app);
$session->set('kecik_session', 'ini nilai session nya');

echo 'kecik_session: '.$session->get('kecik_session').'<br />';

$session->delete('kecik_session');
echo 'kecik_session: '.$session->get('kecik_session').'<br />';


 = new Kecik\Kecik();
$session = new Kecik\Session($app);

$session->clear();

setExpire(int $minute);


 = new Kecik\Kecik();
$session = new Kecik\Session($app);

$session->setExpire(60);  //session akan kadarluarsa setelah 60 menit/1 jam


 = new Kecik\Kecik();
$session = new Kecik\Session($app);
echo $session->getExpire();