<?php
// Require the class file
require('SmartSession.php');
// All methods should be called before send anything to browser (any echo).
// You do not need to call session_start for any operation.
// You could configure session before any operation (call session_set_cookie_params or session_name).
// Example how to set a value to session
SmartSession::getInstance()->set('example', 123);
// Example how to get a value from session by key
$value = SmartSession::getInstance()->get('example');
// Example how to check whether a key exists
$exists = SmartSession::getInstance()->has('example');
// Example how to unset a value from session by key
SmartSession::getInstance()->del('example');
// Example how to persist session data
// Note: You can get/set/del session data after calling saveSession,
// but it is better if you call saveSession after all manipulations.
SmartSession::getInstance()->saveSession();
// Example how to clear session data
SmartSession::getInstance()->clearSession();
// End of file
|