Exemplo n.º 1
0
/**
 * This function returns the user ID of the logged in user on your site.  Technical support will not
 * help you with this for stand-alone installations.  You must purchase the professional installation
 * if you are having trouble.
 *
 * Suggestion: Check out the other integration files in the functions/integrations directory for
 * many examples of how this can be done.  The easiest way is to get the user ID through a cookie.
 *
 * @return the user ID of the logged in user or NULL if not logged in
 */
function get_user_id()
{
    $userid = NULL;
    /*session_name('CAKEPHP');
    		session_start();
    
    		if (isset($_SESSION['userid']))
    		{
    			$userid = $_SESSION['userid'];
    		}*/
    if (isset($_COOKIE['CAKEPHP'])) {
        global $db;
        $result = $db->execute("\n\t\t\t\tSELECT `data`  \n\t\t\t\tFROM `cake_sessions`\n\t\t\t\tWHERE `id` = '" . $_COOKIE['CAKEPHP'] . "'\n\t\t\t");
        if ($result and $db->count_select() > 0) {
            $row = $db->fetch_array($result);
            $session_data = $row['data'];
            session_start();
            session_decode($session_data);
            if (isset($_SESSION['userid'])) {
                $userid = $_SESSION['userid'];
            }
        }
    }
    return $userid;
}
Exemplo n.º 2
0
 public function LoadSessionByToken($token)
 {
     $query = sprintf("SELECT sessionid, sessdata FROM [|PREFIX|]sessions WHERE sessionhash='%s'", $GLOBALS['ISC_CLASS_DB']->Quote($token));
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $session = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
     return @session_decode($session['sessdata']);
 }
 public function buildFiles()
 {
     $ess_usronline = new ess_usronline();
     $ess_usronline->query('DELETE FROM ess_usronline');
     $datSesAct = session_encode();
     $d = dir($session_path = session_save_path());
     while (false !== ($entry = $d->read())) {
         $session_file_name = $session_path . '/' . $entry;
         if (is_readable($session_file_name)) {
             if (is_file($session_file_name)) {
                 $arVarSes = array();
                 $filesize = filesize($session_file_name);
                 if ($filesize > 20) {
                     $_SESSION['datetime'] = $_SESSION['ip'] = $_SESSION['user_id'] = '';
                     $cont = '';
                     $f = fopen($session_file_name, 'r');
                     $cont = fread($f, $filesize);
                     fclose($f);
                     session_decode($cont);
                     if ($_SESSION['user_id'] != "") {
                         $ess_usronline->usuario_id = $_SESSION['user_id'];
                         $ess_usronline->ip = $_SESSION['ip'];
                         $ess_usronline->sesname = $entry;
                         $ess_usronline->size = intval($filesize / 1024);
                         $ess_usronline->filectime = date("Y-m-d H:i:s", filectime($session_file_name));
                         $ess_usronline->datetime = $_SESSION['datetime'];
                         $ess_usronline->save();
                     }
                 }
                 session_decode($datSesAct);
             }
         }
     }
     $d->close();
 }
Exemplo n.º 4
0
 function write($sid, $data)
 {
     $time = time();
     $login = date("Y-m-d H:i:s");
     if ($data) {
         $current = $_SESSION;
         session_decode($data);
         $data = $_SESSION["data"];
         $data = $this->db->real_escape_string($data);
         $_SESSION = $current;
     }
     $query = $this->db->query("SELECT data FROM session_holder WHERE id = '{$sid}'");
     $existRow = $query->num_rows;
     $name = $query->fetch_array();
     if ($existRow > 0) {
         if (empty($_POST["login"])) {
             echo "<span class = 'logMsg'>Welcome back, " . $name[0] . "!</span>";
         } else {
             echo "<span class = 'err'>You have logged in already as " . $name[0] . ".</span>";
         }
     } else {
         if (!empty($data)) {
             $this->result = $this->db->query("INSERT INTO session_holder VALUES('{$sid}', '{$time}', '{$data}', '{$login}')") or die("Cannot login.");
             echo "<span class = 'logMsg'>Log in successful. \n\t\t\t    Session should last " . $this->maxlifetime / 60 . " minutes. \n\t\t\t    See the new Log History here: <a href = " . $_SERVER['REQUEST_URI'] . "> View Log</a></span>";
         }
     }
     return true;
 }
Exemplo n.º 5
0
 /**
  * Write the session data, convert to json before storing
  * @param string $id The SESSID to save
  * @param string $data The data to store, already serialized by PHP
  * @return boolean True if memcached was able to write the session data
  */
 public function write($id, $data)
 {
     $tmp = $_SESSION;
     session_decode($data);
     $new_data = $_SESSION;
     $_SESSION = $tmp;
     return $this->memcache->set("sessions/{$id}", json_encode($new_data), 0, $this->lifetime);
 }
Exemplo n.º 6
0
 /**
  * Get information on a session.
  * 
  * @param string $id A session id.
  * 
  * @return array The session variables.
  */
 public function get($id)
 {
     $realSession = $_SESSION;
     session_decode($this->redis->get(self::PREFIX . $id));
     $userSession = $_SESSION;
     $_SESSION = $realSession;
     return $userSession;
 }
Exemplo n.º 7
0
 /**
  * {@inheritdoc}
  */
 public function read($sessionId)
 {
     $sessionData = Cache::read($sessionId, Configure::read('Session.handler.config'));
     session_decode($sessionData);
     $restoredSessionData = $_SESSION;
     foreach ($_SESSION as $key => $value) {
         unset($_SESSION[$key]);
     }
     return serialize($restoredSessionData);
 }
Exemplo n.º 8
0
 /**
  * Delete sessions with given userId and deviceId.
  * 
  * @see Rublon2FactorCallback::handleLogout()
  */
 protected function handleLogout($userId, $deviceId)
 {
     foreach (glob(ini_get('session.save_path') . "/sess_*") as $file) {
         $contents = @file_get_contents($file);
         session_decode($contents);
         if (!empty($_SESSION['user']) and !empty($_SESSION['user']['login']) and $_SESSION['user']['login'] == $userId and (empty($_SESSION['rublonDeviceId']) or $_SESSION['rublonDeviceId'] == $deviceId)) {
             unlink($file);
         }
     }
 }
Exemplo n.º 9
0
 /**
  * Write the session data, convert to json before storing
  * @param string $id The SESSID to save
  * @param string $data The data to store, already serialized by PHP
  * @return boolean True if redis was able to write the session data
  */
 public function write($id, $data)
 {
     $tmp = $_SESSION;
     session_decode($data);
     $new_data = $_SESSION;
     $_SESSION = $tmp;
     $this->redis->set("sessions/{$id}", json_encode($new_data));
     $this->redis->expire("sessions/{$id}", $this->lifetime);
     return true;
 }
Exemplo n.º 10
0
function ms_read($sessid)
{
    $result = executeQuery("SELECT * FROM currentsession WHERE sessionID='{$sessid}'");
    if ($row = $result->firstrow()) {
        session_decode($row["variables"]);
        return TRUE;
    } else {
        return FALSE;
    }
}
 /**
  * Writes Session json_encoded, so we can access the Session data with other clients like node.js
  */
 public function write($id, $data)
 {
     $tmp = $_SESSION;
     session_decode($data);
     $new_data = $_SESSION;
     $_SESSION = $tmp;
     $id = $this->redisKeyPath() . $id;
     $this->client->set($id, json_encode($new_data));
     $this->client->expire($id, $this->ttl);
     return true;
 }
Exemplo n.º 12
0
 public function testGetPDOSession()
 {
     $session = new \Reservat\Session\Session($this->di, 'PDO');
     session_id('k4o6898jdru8e8gah9mkv5fss5');
     //session_decode($this->sessionData);
     $handler = $session->getHandler();
     session_decode($handler->read('k4o6898jdru8e8gah9mkv5fss5'));
     $this->assertEquals($session->get('ohhai'), 1);
     $this->assertEquals($session->get('userId'), 14);
     $rawSession = $handler->getRaw(session_id());
     $this->assertEquals($rawSession->getUserId(), 14);
 }
Exemplo n.º 13
0
 public function testGateKeeperCheckBasic()
 {
     /* Set our stored DB session MANUALLY for testing */
     session_id('k4o6898jdru8e8gah9mkv5fss5');
     $handler = $this->di->get('session')->getHandler();
     session_decode($handler->read('k4o6898jdru8e8gah9mkv5fss5'));
     $gateway = new \Reservat\Auth\GateKeeper($this->di, $this->manager, 'Basic');
     $result = $gateway->check();
     if ($result['Basic']) {
         $user = $result['Basic']->getUser();
         $this->assertEquals($user->getUsername(), 'abc');
     }
 }
 public final function load($session_id)
 {
     $string = $this->_load($session_id);
     if (!is_string($string) && $string !== false) {
         Mage::throwException('_load should return a string or false');
     }
     if (!$this->_decodeData) {
         return;
     }
     if ($string) {
         session_decode($string);
     } else {
         $_SESSION = array();
     }
 }
Exemplo n.º 15
0
 public static function hookExpiredSession($sessionContents)
 {
     if (session_decode($sessionContents)) {
         if (Zend_Auth::getInstance()->hasIdentity()) {
             $identity = Zend_Auth::getInstance()->getIdentity();
             $audit = new Audit();
             $audit->objectClass = 'Logout';
             $audit->userId = (int) $identity->personId;
             $audit->message = __('user') . ': ' . $identity->username . ' ' . __('was logged out due to session expiration');
             $audit->dateTime = date('Y-m-d H:i:s');
             $audit->_ormPersist = true;
             $audit->persist();
         }
     }
 }
Exemplo n.º 16
0
/**
 * This function returns the user ID of the logged in user on your site.  Technical support will not
 * help you with this for stand-alone installations.  You must purchase the professional installation
 * if you are having trouble.
 *
 * Suggestion: Check out the other integration files in the functions/integrations directory for
 * many examples of how this can be done.  The easiest way is to get the user ID through a cookie.
 *
 * @return the user ID of the logged in user or NULL if not logged in
 */
function get_user_id()
{
    global $db;
    $userid = NULL;
    if (!empty($_COOKIE['CAKEPHP'])) {
        $result = $db->execute("\n\t\t\t\tSELECT data \n\t\t\t\tFROM " . TABLE_PREFIX . "cake_sessions\n\t\t\t\tWHERE id = '" . $db->escape_string($_COOKIE['CAKEPHP']) . "'\n\t\t\t");
        if ($row = $db->fetch_array($result)) {
            $_SESSION['uid'] = 0;
            session_decode($row['data']);
        }
    }
    if (!empty($_SESSION['uid'])) {
        $userid = $_SESSION['uid'];
    }
    return $userid;
}
Exemplo n.º 17
0
 public function write($id, $data)
 {
     if ($this->Unique) {
         $sql = "insert INTO ProteSession SET session_data=?, session_id =?, session_lastaccesstime = CURRENT_TIMESTAMP";
         $this->Db->set_parameters(array($data, $id));
     } else {
         session_decode($data);
         if (!isset($_SESSION['id'])) {
             $sql = "UPDATE ProteSession SET session_data=?, session_lastaccesstime = CURRENT_TIMESTAMP where session_id=?";
             $this->Db->set_parameters(array($data, $id));
         } else {
             $sql = "UPDATE ProteSession SET session_data=?, session_lastaccesstime = CURRENT_TIMESTAMP where session_id=?;UPDATE People SET last_seen=CURRENT_TIMESTAMP() WHERE id=?";
             $this->Db->set_parameters(array($data, $id, $_SESSION['id']));
         }
     }
     $this->Db->insert($sql);
 }
Exemplo n.º 18
0
  public function open($savePath, $sessionName) {
//   $this->savePath = $savePath;
   $this->id = session_id();
   $this->sessionName = $sessionName;
   if (!is_dir($this->savePath)) {
    @mkdirr($this->savePath, 0777);
   }
   @chmod($this->savePath, 0777);
//   echo $this->savePath;
   
   if (file_exists($this->savePath.'/sess_'.$this->id)) {
    $sessiondata = file_get_contents ($this->savePath.'/sess_'.$this->id); // open file containing session data
    session_decode($sessiondata); // Decode the session data
   }
   
   return true;
  }
Exemplo n.º 19
0
 /**
  * 获取1.0版本的Session信息
  *
  * 这里的方式对全局有影响 使用谨慎
  *
  * @return mixed 若不存在,则返回null
  */
 public static function sess1()
 {
     $mc = Arch_Memcache::factory('default');
     $k = $_COOKIE['PHPSESSID'];
     $r = $mc->getOrigin($k);
     if (empty($r)) {
         return null;
     }
     //反序列化Session
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
         $last = $_SESSION;
     }
     session_decode($r);
     $r = $_SESSION;
     $_SESSION = $last;
     return $r;
 }
Exemplo n.º 20
0
	function decode($arg) {
		foreach ($arg as $num => $param) {
			switch ($param) {
				case '-t':
				case '--type':
					$type = strtolower($arg[$num + 1]);
					break;
				case '-s':
				case '--source-file':
					$source = $arg[$num + 1];
					break;
			}
		}

		if (isset($source)) {
			$src = file_get_contents($source);
		}
		if ($type == 'json') {
			$res = json_decode($src);
		}
		if ($type == 'url') {
			$res = urldecode($src);
		}
		if ($type == 'base64') {
			$res = base64_decode($src);
		}
		if ($type == 'html') {
			$res = htmlspecialchars_decode($src);
		}
		if ($type == 'bson') {
			$res = bson_decode($src);
		}
		if ($type == 'session') {
			$res = session_decode($src);
		}
		if ($type == 'utf8') {
			$res = utf8_decode($src);
		}
		if ($type == 'xmlrpc') {
			$res = xmlrpc_decode($src);
		}
		return $res;
	}
Exemplo n.º 21
0
function getUserID()
{
    $userid = 0;
    if (!empty($_SESSION['basedata']) && $_SESSION['basedata'] != 'null') {
        $_REQUEST['basedata'] = $_SESSION['basedata'];
    }
    if (!empty($_REQUEST['basedata'])) {
        $userid = $_REQUEST['basedata'];
    }
    if (!empty($_COOKIE['PHPSESSID'])) {
        $sql = "SELECT data from " . TABLE_PREFIX . "core_session where id = '" . mysql_real_escape_string($_COOKIE['PHPSESSID']) . "'";
        $result = mysql_query($sql);
        $row = mysql_fetch_array($result);
        $_SESSION['Zend_Auth']['storage'] = 0;
        session_decode($row['data']);
        $userid = $_SESSION['Zend_Auth']['storage'];
    }
    return $userid;
}
Exemplo n.º 22
0
 function isBackendUserLoggedIn()
 {
     if (!array_key_exists('adminhtml', $_COOKIE)) {
         return false;
     }
     if (!session_id()) {
         session_start();
     }
     $oldSession = $_SESSION;
     Mage::app();
     $sessionFilePath = Mage::getBaseDir('session') . DS . 'sess_' . $_COOKIE['adminhtml'];
     $sessionContent = file_get_contents($sessionFilePath);
     session_decode($sessionContent);
     /** @var Mage_Admin_Model_Session $session */
     $session = Mage::getSingleton('admin/session');
     $loggedIn = $session->isLoggedIn();
     //set old session back to current session
     $_SESSION = $oldSession;
     return $loggedIn;
 }
Exemplo n.º 23
0
 function process()
 {
     $menuCont = new ModMenuContainer();
     $userObj = session_id('REGI-userObject') ? session_decode('REGI-userObject') : "";
     if (!is_object($userObj)) {
         $menuArr = $menuCont->getMenu('all');
     } else {
         $menuArr = $menuCont->getMenu($userObj->getUserGroupeName());
     }
     if (count($menuArr) == 0) {
         new ErrorHandler(get_class($this), "process", "", "GROUP ERROR", "The group, the user belongs to doesn't exist!");
     }
     for ($i = 0; $i < count($menuArr); $i++) {
         $menuName = $menuArr[$i]->getProperty('MENU_NAME');
         $menuTitle = $menuArr[$i]->getProperty('MENU_TITLE');
         $itemArr = $menuCont->getMenItem($menuName, $this->_language);
         $this->_template->set_var("menu_body", $this->_html->getSimpleMenu($itemArr));
     }
     $this->_template->parse("TOTAL_MENU_BLOCK", "total_menu_block");
     $this->_template->parse($this->_outputName, $this->_mainBlock);
 }
Exemplo n.º 24
0
 public function getEMAdminUserId()
 {
     try {
         if (array_key_exists('adminhtml', $_COOKIE)) {
             $sessionFilePath = Mage::getBaseDir('session') . DS . 'sess_' . $_COOKIE['adminhtml'];
             $sessionFile = file_get_contents($sessionFilePath);
             $oldSession = $_SESSION;
             session_decode($sessionFile);
             $adminSessionData = $_SESSION;
             $_SESSION = $oldSession;
             if (array_key_exists('user', $adminSessionData['admin'])) {
                 $adminUserObj = $adminSessionData['admin']['user'];
                 $_emAdminUserId = $adminUserObj['user_id'];
                 $this->_adminFormKey = $adminSessionData['core']['_form_key'];
             }
         }
     } catch (Exception $e) {
         return false;
     }
     return $_emAdminUserId;
 }
 function write($sid, $data)
 {
     if ($data) {
         // unserialize $_SESSION to get name datas, then reserialized it back.
         $this->current = $_SESSION;
         session_decode($data);
         $data = $_SESSION["data"];
         $data = $this->db->real_escape_string($data);
         $_SESSION = $this->current;
         // set up variables
         $time = time();
         $login = date("Y-m-d H:i:s");
         // write new row in database.
         $this->result = $this->db->prepare("INSERT INTO session_holder VALUES(?, ?, ?, ?)");
         $this->result->bind_param("siss", $sid, $time, $data, $login);
         $this->result->execute();
         echo "<span class = 'logMsg'>Log in successful. Session should last " . $this->maxlifetime / 60 . " minutes.</span>";
         $this->result->close();
         return true;
     }
 }
 /**
  * @brief validate $sessionid and restore $_SESSION.
  *
  * @param[in]  $sessionid session ID
  * @return     array($result,$uid,$session)
  *             if $result==true && uid != UID_GUEST, $sessionid was valid, $uid and $session are user ID and XooNIpsSession object.
  *             if $result==true && uid == UID_GUEST, $sessionid was valid and $session=false.
  *             if $result==false,                    $sessionid was invalid and $uid=$session=false.
  *
  */
 function restoreSession($sessionid)
 {
     global $_SESSION;
     session_id($sessionid);
     // restore $_SESSION
     $xoops_sess_handler =& xoops_gethandler('session');
     $sess_data = $xoops_sess_handler->read($sessionid);
     if ($sess_data == '') {
         return array(false, false, false);
     } else {
         session_decode($sess_data);
     }
     $uid = $_SESSION['xoopsUserId'];
     if ($uid == UID_GUEST) {
         // reject guest if guest is forbidden
         $xconfig_handler =& xoonips_getormhandler('xoonips', 'config');
         $target_user = $xconfig_handler->getValue(XNP_CONFIG_PUBLIC_ITEM_TARGET_USER_KEY);
         if ($target_user != XNP_CONFIG_PUBLIC_ITEM_TARGET_USER_ALL) {
             return array(false, false, false);
         }
         $session = false;
     } else {
         // validate session
         $sess_handler =& xoonips_getormhandler('xoonips', 'session');
         $sessions =& $sess_handler->getObjects(new Criteria('sess_id', $sessionid));
         if (!$sessions || count($sessions) != 1) {
             return array(false, false, false);
         }
         $member_handler =& xoops_gethandler('member');
         $xoops_user =& $member_handler->getUser($_SESSION['xoopsUserId']);
         if ($xoops_user) {
             $GLOBALS['xoopsUser'] =& $xoops_user;
         }
         $session = $sessions[0];
         $session->setVar('updated', time(), true);
         // not gpc
         $sess_handler->insert($session);
     }
     return array(true, $uid, $session);
 }
Exemplo n.º 27
0
 public function Start()
 {
     if ($this->getIsSessionStarted(true)) {
         return;
     }
     $request_type = getenv('HTTPS') == 'on' ? 'SSL' : 'NONSSL';
     // set the cookie domain
     $cookie_domain = $request_type == 'NONSSL' ? \src\classes\Environment::HTTP_COOKIE_DOMAIN : \src\classes\Environment::HTTPS_COOKIE_DOMAIN;
     $cookie_path = $request_type == 'NONSSL' ? \src\classes\Environment::HTTP_COOKIE_PATH : \src\classes\Environment::HTTPS_COOKIE_PATH;
     $currentSession = null;
     // set the session cookie parameters
     if (function_exists('session_set_cookie_params')) {
         session_set_cookie_params(0, $cookie_path, $cookie_domain);
     } elseif (function_exists('ini_set')) {
         ini_set('session.cookie_lifetime', '0');
         ini_set('session.cookie_path', $cookie_path);
         ini_set('session.cookie_domain', $cookie_domain);
     }
     $sessionId = isset($_COOKIE['sessionId']) ? $_COOKIE['sessionId'] : md5(uniqid(rand(), true));
     if (!isset($_COOKIE['sessionId'])) {
         setcookie('sessionId', $sessionId, time() + 60 * 60 * 24);
     } else {
         session_id($sessionId);
         session_start();
         $currentSession = session_encode();
         session_destroy();
         $sessionId = md5(uniqid(rand(), true));
         setcookie('sessionId', $sessionId, time() + 60 * 60 * 24);
     }
     session_id($sessionId);
     session_start();
     if ($currentSession !== null) {
         session_decode($currentSession);
     }
     $hasCookies = false;
     $this->setIsSessionStarted(true);
     $this->RegisterVariable('sessionId', $sessionId);
 }
Exemplo n.º 28
0
function getUserID()
{
    $userid = 0;
    if (!empty($_SESSION['basedata']) && $_SESSION['basedata'] != 'null') {
        $_REQUEST['basedata'] = $_SESSION['basedata'];
    }
    if (!empty($_REQUEST['basedata'])) {
        $userid = $_REQUEST['basedata'];
    }
    if (!empty($_COOKIE['CAKEPHP'])) {
        $sql = "SELECT data from " . TABLE_PREFIX . "cake_sessions where id='" . $_COOKIE['CAKEPHP'] . "'";
        $query = mysql_query($sql);
        $row = mysql_fetch_array($query);
        if (!empty($row['data'])) {
            $_SESSION['uid'] = 0;
            session_decode($row['data']);
        }
    }
    if (!empty($_SESSION['uid'])) {
        $userid = $_SESSION['uid'];
    }
    return $userid;
}
Exemplo n.º 29
0
/**
 * This function returns the user ID of the logged in user on your site.  Technical support will not
 * help you with this for stand-alone installations.  You must purchase the professional installation
 * if you are having trouble.
 *
 * Suggestion: Check out the other integration files in the functions/integrations directory for
 * many examples of how this can be done.  The easiest way is to get the user ID through a cookie.
 *
 * @return the user ID of the logged in user or NULL if not logged in
 */
function get_user_id()
{
    global $db;
    $userid = NULL;
    if (!empty($_COOKIE['PHPSESSID'])) {
        $result = $db->execute("\n\t\t\t\tSELECT data\n\t\t\t\tFROM " . TABLE_PREFIX . "core_session \n\t\t\t\tWHERE id = '" . $db->escape_string($_COOKIE['PHPSESSID']) . "'\n\t\t\t");
        if ($row = $db->fetch_array($result)) {
            $_SESSION['Zend_Auth']['storage'] = 0;
            session_decode($row['data']);
            if (filter_var($_SESSION['Zend_Auth']['storage'], FILTER_VALIDATE_EMAIL)) {
                $email = $_SESSION['Zend_Auth']['storage'];
                $result = $db->execute("\n\t\t\t\t\t\tSELECT user_id\n\t\t\t\t\t\tFROM " . TABLE_PREFIX . DB_USERTABLE . "\n\t\t\t\t\t\tWHERE email = '" . $db->escape_string($email) . "'\n\t\t\t\t\t");
                if ($row = $db->fetch_array($result)) {
                    $userid = $row['user_id'];
                }
            } else {
                if (filter_var($_SESSION['Zend_Auth']['storage'], FILTER_VALIDATE_INT)) {
                    $userid = $_SESSION['Zend_Auth']['storage'];
                }
            }
        }
    }
    return $userid;
}
 function write($sid, $data)
 {
     if ($this->result->num_rows === 0) {
         // unserialize $_SESSION to get name datas, then reserialized it back.
         if ($data) {
             $this->current = $_SESSION;
             session_decode($data);
             $data = $_SESSION["data"];
             $data = $this->db->real_escape_string($data);
             $_SESSION = $this->current;
         }
         // before logginn in, make sure the username and password matches. Start by querying database.
         $this->nameMatch = $this->db->query("SELECT data FROM user_info WHERE data = '{$data}'") or die("Cannot access database for name matching.");
         $this->pwMatch = $this->db->query("SELECT passWd FROM user_info WHERE data = '{$data}'") or die("Cannot access database for password matching.");
         if ($this->nameMatch->num_rows > 0 && $this->pwMatch->num_rows > 0) {
             // since username was found, fetch the user name and password.
             $this->nameMatch = $this->nameMatch->fetch_array();
             $this->pwMatch = $this->pwMatch->fetch_array();
             // check for matching between input and database.
             if ($data == $this->nameMatch[0] && $_POST["passWd"] == $this->pwMatch[0]) {
                 // set up variables
                 $time = time();
                 $login = date("Y-m-d H:i:s");
                 // write new row in database.
                 $this->newRow = $this->db->query("INSERT INTO session_holder VALUES('{$sid}', '{$time}', '{$data}', '{$login}')") or die("Cannot login.");
                 if (isset($this->newRow)) {
                     echo "<span class = 'logMsg'>Log in successful. Session should last " . $this->maxlifetime / 60 . " minutes.";
                 }
             } else {
                 echo "Username and password does not match.";
             }
             // Ends matching. Close databases associated with matching.
         }
     }
     return true;
 }