$session_db = null; $logged_in_user = NULL; $json = array(); //*********************************************// // Main session handling workflow operations. // // Calling to any of several helper functions // // below. // //*********************************************// try { // if you cannot get a connection to the database // you cannot do anything else... Start processing. $mySQLi = new MySQLi_DB($_sqli_conf); if ($mySQLi->is_valid()) { // you've connected // get a pointer to the database for use in all future operations $session_db = $mySQLi->getLink(); // insert or update last accessed on each logged-in session refresh if (isset($_COOKIE['nvsa_session'])) { $kp_session = (array) json_decode(base64_decode($_COOKIE['nvsa_session'])); if (!isset($logged_in_user)) { $logged_in_user = new NVSA_USER($session_db, $kp_session); } $qry = "INSERT INTO `wb-user-meta` (user_id,meta_key,meta_value) VALUES ('" . $logged_in_user->ID() . "','last_accessed', CURRENT_TIMESTAMP)" . "ON DUPLICATE KEY UPDATE meta_value=CURRENT_TIMESTAMP;"; $session_db->query($qry); } // note: tuck all echo statments away so they cannot accidentally fire // when this file is included. Only available upon "Action" request if (isset($_POST['action']) && $_POST['action'] !== '') { // if attempting to login if ($_POST['action'] == 'login') { // if ( user_logged_in(true)==true )