/** * Creates a new session for the provided username and sets cookie * @param string $username */ private function newSession($username) { $hash = md5(microtime()); // unique session hash // Fetch User ID : $queryUid = $this->db->select("SELECT id FROM " . PREFIX . "users WHERE username=:username", array(":username" => $username)); $uid = $queryUid[0]->id; // Delete all previous sessions : $this->db->delete(PREFIX . "sessions", array("username" => $username)); $ip = $_SERVER['REMOTE_ADDR']; $expiredate = date("Y-m-d H:i:s", strtotime(SESSION_DURATION)); $expiretime = strtotime($expiredate); $this->db->insert(PREFIX . "sessions", array("uid" => $uid, "username" => $username, "hash" => $hash, "expiredate" => $expiredate, "ip" => $ip)); Cookie::set('auth_session', $hash, $expiretime, "/", FALSE); }
/** * Creates a new session for the provided username and sets cookie * @param string $username * @param bool $rememberMe */ private function newSession($username, $rememberMe) { $hash = md5(microtime()); // unique session hash // Fetch User ID : $queryUid = $this->authorize->getUserID($username); $uid = $queryUid[0]->userID; // Delete all previous sessions : $this->authorize->deleteSession($username); $ip = $_SERVER['REMOTE_ADDR']; $expiredate = $rememberMe ? date("Y-m-d H:i:s", strtotime(SESSION_DURATION_RM)) : date("Y-m-d H:i:s", strtotime(SESSION_DURATION)); $expiretime = strtotime($expiredate); $info = array("uid" => $uid, "username" => $username, "hash" => $hash, "expiredate" => $expiredate, "ip" => $ip); $this->authorize->addIntoDB("sessions", $info); Cookie::set('auth_session', $hash, $expiretime, "/", FALSE); }