I have a file in php that is responsible for closing the session but before it must change the status in several different databases, this process takes a bit, so the browser stays waiting and until it ends redirects to index .php This is the code to close the session ...
<?php
include 'HistorialController.php';
include_once 'clases/Sistemas.php';
session_start();
$_SESSION['login'] = false;
$_SESSION['recordar'] = 'no';
$liberar = new Sistemas('');
$liberar->libera();
unset($_SESSION['login']);
header('Location: index.php');
?>
The release code is the following ...
/**
* Metodo que Libera las imagenes ocupadas por el usuario al salir de la session
**/
public function libera(){
$id_user = $_SESSION['id_usuario'];
$actualiza = "UPDATE Imagen SET estatuspm_web=0 WHERE id_usuariopm_web=" . $id_user." and estatuspm_web=1";
for ($i = 0; $i < count($this->listaSistemas); $i++){ //RECORRIDO DE LOS SISTEMAS
$sistemaActual = $this->listaSistemas[$i];
$baseConn = new BaseConexion("Sistema_".$sistemaActual);
if ($conn = $baseConn->conectar()) {
sqlsrv_query( $conn, $actualiza, $params);
}
$baseConn->close();
}
}