Example #1
0
 */
$key = 'example';
$name = 0;
Session::getKey($key, $name);
/*
 * Get a sessions array value by key and value
 */
$key = 'example';
$value = 'I Love PHP';
Session::deleteKey($key, $value);
/*
 * Delete session by key name
 */
$key = 'example';
Session::delete($key);
/**
* deletes the session (= logs the user out)
*/
Session::destroy();
/*
* Flash messages by deleting session after it is shown
*/
$key = 'SUCCESS';
$string = 'Login is success!';
Session::flash($key, $string);
/*
 * Check session inacktivity. Set exipiry in time format
 */
$expiry = 1800;
Session::check($expiry);
var_dump($_SESSION);
Example #2
0
    .feedback.info { 
        color: #00529B; 
        background-color: #BDE5F8; 
    } 
</style> 
<?php 
use thom855j\PHPSecurity\Session;
// echo out positive messages
if (Session::exists('SUCCESS')) {
    foreach ((array) Session::flash('SUCCESS') as $feedback) {
        echo '<div  class="feedback success">' . $feedback . '</div>';
    }
}
// echo out negative messages
if (Session::exists('ERRORS')) {
    foreach ((array) Session::flash('ERRORS') as $feedback) {
        echo '<div class="feedback error">' . $feedback . '</div>';
    }
}
// echo out warning messages
if (Session::exists('WARNINGS')) {
    foreach ((array) Session::flash('WARNINGS') as $feedback) {
        echo '<div class="feedback warning">' . $feedback . '</div>';
    }
}
// echo out info messages
if (Session::exists('INFO')) {
    foreach ((array) Session::flash('INFO') as $feedback) {
        echo '<div class="feedback info">' . $feedback . '</div>';
    }
}