Location: PHPKode > projects > MyNotebook > mynotebook/notes.admin.php
<?php
  // Some login stuff
  
  function logout ()
  {
      $_SESSION["login"] = "";
      $sid = $_SESSION["sid"];
      session_unset(); 
      $logout = session_destroy();
      $_SESSION["sid"] = $sid;
      session_start();
      session_regenerate_id();
      if ($logout)
      {
        echo "Logout successful<br>";
        echo "Back to " . "<a href=\"index.php\">loginpage</a>";
      }
      else
      {
        echo "Session could not be destroyed<br>";
        echo "Back to " . "<a href=\"index.php\">loginpage</a>";
      }
  
      exit;
  }

  function showLoginForm ()
  {
    echo "<br><br>";
    echo "<form action=\"index.php\" method=\"POST\"> ";
    echo "Password:&nbsp;<input type=\"password\" name=\"Pwd\"/>";
    echo "<input type=\"submit\" value=\"Ok\">";
    echo "<input type=\"hidden\" name=\"Sid\" value=\"" . session_id() . "\">";
    echo "<input type=\"hidden\" name=\"Action\" value=\"Login\">";
    echo "</form>";
    
    
  }

  function isLoggedIn ()
  {
    global $user_pwd;
    if ($_SESSION["login"] != sha1($user_pwd))
    {
      return false;
    }
    else
    {
      return true;
    }  
  }
  
  function login ()
  {
    global $pwd;
    global $user_pwd;
    if (isset ($pwd))
    {
      if ($pwd == $user_pwd)
      {
        if ($_POST["Sid"] == session_id())
        {
          $_SESSION["login"] = sha1($pwd);
        }
        else
        {
			echo "Session timed out! Please login again!<br>";
			echo "Back to " . "<a href=\"index.php\">loginpage</a>";
			exit;
        }
      }
      else
      {
        echo "Wrong user password!<br>";
        echo "Back to " . "<a href=\"index.php\">loginpage</a>";
        exit;
      }
    }  
  }
?>
Return current item: MyNotebook