<?php
$ruta = "../";
require_once '../class/c_login.php';

# print_r($_POST); exit;
extract($_POST); // $usuario
Login::log_out();

$user = query("SELECT * FROM FS_USUARIO WHERE ID = :id", [":id" => $usuario]);
// die(json_encode($user));

$facultad = [
    "facultad_id" => $user["facultad"],
    "facultad" => $user["facultad_nombre"]
];

$rol = [
    "rol_id" => $user["rol"],
    "rol" => $user["titulo"]
];

$admin = false;

$periodo = $user["periodo"];

$user = [
    "id" => $user["id"],
    "nombre" => $user["username"]
];

$user = new Login($user, $facultad, $rol, $admin, $periodo);
if (isset($_SESSION))
    session_start();
$_SESSION['user'] = serialize($user);

header("Location: ../main.php");
exit;