<?php
  session_save_path(dirname($_SERVER["SCRIPT_FILENAME"])."/sessions");
  session_start();
  session_register("user");
  session_register("pass");
  session_register("login");
  $action=$_POST["action"];
  $querystring=$_POST["querystring"];
  if($action=="Entrar") {
    $user=$_POST["user"];
    $pass=md5($_POST["pass"]);
    if($user!="") {
      $_SESSION["user"]=$user;
      $_SESSION["pass"]=$pass;
      $_SESSION["login"]=1;
    }
  } else if($action=="Sortir") {
    $_SESSION["user"]="";
    $_SESSION["pass"]="";
  }
  if ($action!="" && isset($_SESSION["norevalidate"])) unset($_SESSION["norevalidate"]);
  if (strpos($querystring,"page=passperduda")!==FALSE) $querystring="";

  header("Location: inicio.php?".$querystring);
  exit;
?>
