Good community,
In this way I use the sessions in the main file to differentiate the interfaces of a common user to an administrator, for example:
<?php
session_start();
if (isset($_SESSION['usuario']))
{
if ($_SESSION['usuario']['desc_tipo_usuario'] != "adminEmpresa")
{
header('Location: adminEmpresa.php');
}
}
else {
header('Location: index.php');
}
?>
But currently I have more than 15 PHP files within which I declare the use of SESSIONS:
session_start();
$nit_empresa = $_SESSION['usuario']['nit'];
$id_empresa = $_SESSION['usuario']['id_empresa'];
I have checked each one of the querys and all of them respond with a prudent speed for the loading of data (eg use of variable):
SELECT
pemp.nombre_punto,
cdes.ciudad,
cdes.id_departamento,
dpto.departamento,
pemp.descripcion_punto,
tusr.id_tipoDeUsuario,
tusr.desc_tipo_usuario,
empr.id_empresa,
empr.nit,
empr.ruta_logo,
prna.usuario,
prna.password
FROM puntoempresa pemp
INNER JOIN ciudades cdes
ON cdes.id_ciudad = pemp.id_ciudades_punto
INNER JOIN departamento dpto
ON dpto.id_departamento = cdes.id_departamento
INNER JOIN persona prna
ON prna.id_usuario_punto = pemp.id_puntoEmpresa
INNER JOIN tipodeusuario tusr
ON tusr.id_tipoDeUsuario = prna.id_tipoUsuario
INNER JOIN empresa empr
ON empr.id_empresa = prna.empresa_per
WHERE empr.nit = '$nit_empresa'
AND empr.id_empresa = '$id_empresa'
Later on in my consultations I use them as variables to have a much more structured query of the data, but my doubt arises as to what the use of the sessions in all my CRUD files, is altering the loading speed of all the project as such.
Since at the moment of using "F5" or using the update button the browser takes an average load of 15 seconds, which bothers most users who use the system.
Looking for a bit I found this type of problem, how could you optimize the use of sessions?:
Heavy user sessions: Each user accessing the site or web application requires a memory capacity for the server to process their requests and deliver the content. If this need for resources is very high, the slowness of the service will become noticeable exponentially each time more users access. In this case you should review and optimize the code to make each session lighter or increase the resources available correctly