Caducarla al cerrar el navegador.
Hola amigos. Agradezco a "masterojitos" con la ayuda que me proporcionó con lo de javascript.
Bueno tengo este archivo, y quiero que me orienten sobre esto, he encontrado información y probé muchas cosas y nada de nada, he aqui mi codigo:
Código PHP:
<?php require_once('Connections/segurodb.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "desconectado.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
//defino la sesión que demuestra que el usuario está autorizado
$_SESSION["ultimoAcceso"]= date("Y-n-j H:i:s");
//sino, calculamos el tiempo transcurrido
$fechaGuardada = $_SESSION["ultimoAcceso"];
$ahora = date("Y-n-j H:i:s");
$tiempo_transcurrido = (strtotime($ahora)-strtotime($fechaGuardada));
//comparamos el tiempo transcurrido
if($tiempo_transcurrido >= 30) {
//si pasaron 10 minutos o más
session_destroy(); // destruyo la sesión
}else {
$_SESSION["ultimoAcceso"] = $ahora;
}
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "error.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_rc_logueo = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_rc_logueo = $_SESSION['MM_Username'];
}
mysql_select_db($database_segurodb, $segurodb);
$query_rc_logueo = sprintf("SELECT empresa FROM registro WHERE nit = %s", GetSQLValueString($colname_rc_logueo, "int"));
$rc_logueo = mysql_query($query_rc_logueo, $segurodb) or die(mysql_error());
$row_rc_logueo = mysql_fetch_assoc($rc_logueo);
$totalRows_rc_logueo = mysql_num_rows($rc_logueo);
$colname_rc_prod = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_rc_prod = $_SESSION['MM_Username'];
}
mysql_select_db($database_segurodb, $segurodb);
$query_rc_prod = sprintf("SELECT * FROM productos WHERE idprod = %s", GetSQLValueString($colname_rc_prod, "int"));
$rc_prod = mysql_query($query_rc_prod, $segurodb) or die(mysql_error());
$row_rc_prod = mysql_fetch_assoc($rc_prod);
$totalRows_rc_prod = mysql_num_rows($rc_prod);
$colname_rc_sin = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_rc_sin = $_SESSION['MM_Username'];
}
mysql_select_db($database_segurodb, $segurodb);
$query_rc_sin = sprintf("SELECT * FROM sinclave WHERE idprod = %s", GetSQLValueString($colname_rc_sin, "int"));
$rc_sin = mysql_query($query_rc_sin, $segurodb) or die(mysql_error());
$row_rc_sin = mysql_fetch_assoc($rc_sin);
$totalRows_rc_sin = mysql_num_rows($rc_sin);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Titulo</title><link rel="shortcut icon" href="favicon.ico" />
<link href="css/css.css" rel="stylesheet" type="text/css" />
<script src="js/AC_RunActiveContent.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
</script>
</head>
<body>
<div align="center">
<table width="835" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<!--TABLA PRINCIPAL-->
<!--FIN TABLA PRINCIPAL-->
<tr>
<td width="835" height="38" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<!--TABLA MENU-->
<tr>
<td width="35" height="38"> </td>
<td width="144" align="left" valign="middle" class="deslgueo"><a href="<?php echo $logoutAction ?>">Desconectarme</a></td>
<td width="572" align="right" valign="middle" class="camposlog">Bienvenido, Sres. <?php echo $row_rc_logueo['empresa']; ?>. </td>
<td width="84"> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="67"> </td>
</tr>
</table>
</div>
</body>
</html>
<?php
mysql_free_result($rc_logueo);
mysql_free_result($rc_prod);
mysql_free_result($rc_sin);
?>
Gracias, también intente algo del php.ini......y nada a ver si me pueden echar una ayudadita...