Foros del Web » Programando para Internet » PHP »

Evitar Doble Logeo Con Php

Estas en el tema de Evitar Doble Logeo Con Php en el foro de PHP en Foros del Web. Hola como estan, estoy diseñando un sistema de control de usuarios con ajax+php+mysql, y tengo un problema con la actualizacion de las sessiones por paginas ...
  #1 (permalink)  
Antiguo 29/11/2006, 14:18
 
Fecha de Ingreso: noviembre-2006
Mensajes: 2
Antigüedad: 17 años, 5 meses
Puntos: 0
Evitar Doble Logeo Con Php

Hola como estan, estoy diseñando un sistema de control de usuarios con ajax+php+mysql, y tengo un problema con la actualizacion de las sessiones por paginas y de la base de datos, hay que les pongo el codigo:

archivo ajax:

function MyAjax() {
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}

return xmlhttp;
}

funciones.php

<?

function update($username){
$con=mysql_connect("localhost","root","");
$db=mysql_select_db("hostpbx",$con);
$query_update="update logeo set sw='no' where login='$username' and sw='yes'";
$j=mysql_query($query_update,$con);
mysql_close($con);
}



?>
user.php

<?
session_start();
include('./funciones.php');

if(isset($_SESSION)){
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<script script language="Javascript" type="text/javascript">
function MyAjax() {
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}

return xmlhttp;
}

function cargarContenido()
{
var miAjaxObj = MyAjax();
miAjaxObj.open("GET","user.php?t1=no",true);
miAjaxObj.onreadystatechange=function(){
if (miAjaxObj.readyState==4){
if (miAjaxObj.status==200){
alert("ejecutado");
}
}
}
miAjaxObj.send(null);

}
//window.onUnload=cargarContenido;
</script>
</head>
<body onUnload="cargarContenido()">

<h2> <? echo $username; ?></h2><br>
<? if(isset($login))
echo '<h2> Bienvenido </h2><br>';
else
header('location: ./index.php');
?>


</body>
</html>
<?
if(isset($t1)){
update($username);
}
}else
header('location: ./index.php');
?>
la base de datos un utiliza un flag que se llama sw, para el control de los usuarios que entran.

Gracias y por su coloboracion y espero sus prontas respuestas!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:31.