-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
41 lines (38 loc) · 783 Bytes
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
// Session start
require_once( 'fd_admin.php' );
// Utils
require_once( 'util.php' );
// siempre se llegará por post
// Para entrar como para salir
$accion = $_POST['accion'];
error_log( $accion );
// 'login' y 'logout'
if ( match('login', $accion) )
{
$res = login( $_POST['usuario'], $_POST['contrasena'] );
if ( $res['resultado'] )
{
session_start();
$_SESSION['sid'] = uniqid();
$_SESSION['usuario'] = $res['usuario'];
// Login exitoso
// Crear caja
$_SESSION['caja'] = obtenerCaja();
}
}
else if ( match('logout', $accion) )
{
// Logout
session_start();
error_log('Cerrando sesion');
session_destroy();
$res = array('resultado' => true);
}
else
{
$res = array( 'resultado' => false );
}
header( 'Content-Type: json' );
echo json_encode( $res )
?>