Beispiel #1
0
         $response["username"] = $_SESSION["username"];
         echo json_encode($response);
     } else {
         $response["success"] = false;
         $response["errorMsg"] = "Session not set";
         echo json_encode($response);
     }
 } else {
     if ($action == "verifySession") {
         $uid_ = $_POST['uid'];
         $username_ = $_POST['username'];
         //Check if uid and username stored in session is still in the database
         $result = $dbFunctions->isSessionExists($uid_, $username_);
         if ($result == true) {
             //If session is still in database, check if it has expired
             $result = $dbFunctions->isSessionExpired($uid_, $username_);
             if ($result == true) {
                 //Session has expired
                 //Delete username from the database
                 $dbFunctions->deleteUser($username_);
                 $response["success"] = false;
                 $response["errorMsg"] = "Your session has expired, and you have been logged out.";
                 echo json_encode($response);
             } else {
                 //Session has not expired
                 $response["success"] = true;
                 echo json_encode($response);
             }
         } else {
             $response["success"] = false;
             $response["errorMsg"] = "Your session has expired, and you have been logged out.";