Foros del Web » Programando para Internet » PHP »

Sesiones

Estas en el tema de Sesiones en el foro de PHP en Foros del Web. Hola, estoy necesitando su ayuda tengo estos script : Login Código PHP: <?php /* This script was downloaded at: LightPHPScripts.com Please support us by visiting out website and letting people know of it. Produced under: LGPL */ /* Start session */ if( $startSession  ==  ...

  #1 (permalink)  
Antiguo 07/06/2011, 12:09
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Sesiones

Hola, estoy necesitando su ayuda

tengo estos script :

Login

Código PHP:
<?php

/*
This script was downloaded at:
LightPHPScripts.com
Please support us by visiting
out website and letting people
know of it.
Produced under: LGPL
*/

/* Start session */
if($startSession == TRUE){ session_start();}

/* Config file */
include('config.php');

/* Check for submition */
if($_POST['submitID'] == 1){
    
    
/* Connect to database */
    
if($connectDatabase == TRUE){$action=TRUE;include('connect.php');}
        
    
/* sanitize and check info */
    
$userName mysql_real_escape_string($_POST['userName'],$dbc);
    
$password mysql_real_escape_string($_POST['password'],$dbc);
    
    if(
$userName == NULL) { $message 'Por favor ingrese nombre de usuario.';}
    if(
$message == NULL && $password == NULL){ $message 'Por favor, introduzca la Clave.';}
    
    if(
$message == NULL)
    {                
        
$userQuery mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM " $tableName .
        
" WHERE `" $userNameField "`='$userName' AND `" $userPasswordField "`='$password'"));        
        
        
/* If usercount is more than 0 -> ok */
        
if($userQuery[0] > 0){
            
/* Disconnect from database */
            
if($connectDatabase == TRUE){$action=FALSE;include('connect.php');}
    
            
$_SESSION['isLoged'] = 'yes';
            
$_SESSION['userName'] = $userName;
            
            
/* add cookies ?*/
            /* expire in 1 hour */
            
if($useCookies == TRUE)
            {
                
setcookie("isLoged"'yes'time()+logedInFor"/"".$domainName"1);
                
setcookie("userName"$userNametime()+logedInFor"/"".$domainName"1);
            }

            
/* Redirect to login page */
            
header("Location: $loginPage");
            exit();
        } else {
            
$message 'No válido nombre de usuario y / o Clave!';
        }
    }
    
/* Disconnect from database */
    
if($connectDatabase == TRUE){$action=FALSE;include('connect.php');}
}
?><style type="text/css">
<!--
#Layer8 {
    position:absolute;
    left:510px;
    top:220px;
    width:100px;
    height:300px;
    z-index:1;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #0099CC;
}
#Layer9 {
    position:absolute;
    left:200px;
    top:500px;
    width:900px;
    height:50px;
    z-index:1;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #0099FF;
    border-top-width: thin;
    border-top-style: dashed;
    border-top-color: #3399FF;
}
-->
</style>
<div id="Layer8">
<!--
/*
This script was downloaded at:
LightPHPScripts.com
Please support us by visiting
out website and letting people
know of it.
Produced under: LGPL
*/
-->
<?php

/* Display error messages */
if($message != NULL){?>
<div align="center">
  <table width="250"  border="0" cellpadding="3" cellspacing="0" bgcolor="#FFCCCC">
    <tr>
      <td><div align="center"><strong><font color="#FF0000"><?=$message;?></font></strong></div></td>
    </tr>
  </table>
  <?php ?><form action="<? echo $_SERVER['PHP_SELF'];?>" method="post" name="login" id="login" style="display:inline;">
  <table width="250" align="center" cellpadding="5" cellspacing="0">
    <tr bgcolor="#99CC99"> 
      <td colspan="2" bgcolor="B3D9EC"><div align="center"><font color="#FFFFFF"><strong>Validaci&oacute;n de Usuario y Clave:</strong></font></div></td>
    </tr>
    <tr> 
      <td width="47%"><strong>Usuario:</strong></td>
      <td width="53%"><input name="userName" type="text" id="userName"></td>
    </tr>
    <tr> 
      <td><strong>Clave:</strong></td>
      <td><input name="password" type="password" id="password"></td>
    </tr>
    <tr> 
      <td colspan="2"><div align="center"><font face="Georgia, Times New Roman, Times, serif"><strong>
          <input name="Submit" type="submit" id="Submit" value="Ingresar"> <a href="register.php">Registrarme</a> 
          <input name="submitID" type="hidden" id="submitID" value="1">
</strong></font> </div></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center">Compartilo <a href="http://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fofertasdiarias.net%2F&amp;t="><img src="imagenes/facebook.gif" alt="2" width="16" height="16" border="0" /></a> <a href="https://www.google.com/accounts/ServiceLogin?passive=1209600&amp;continue=https%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26bkmk%3Dhttp%253A%252F%252Fofertasdiarias.net%252F&amp;hl=es"><img src="imagenes/google.gif" alt="3" width="16" height="16" border="0" /></a> <a href="http://twitter.com/?status=Hoy - Ofertasdiarias Comprar y vender http%3A//ofertasdiarias.net/"><img src="twitter.gif" alt="4" width="16" height="16" border="0" /></a> <a href="https://secure.delicious.com/login?jump=http%3A%2F%2Fwww.delicious.com%2Fsave%3Furl%3Dhttp%253A%252F%252Fofertasdiarias.net%252F%26title%3DHoy%2520-%2520Ofertasdiarias%2520Comprar%2520y%2520vender%26notes%3D%26tags%3D%26noui%3Dno%26jump%3Dyes%26time%3D1306946854%26share%3Dyes%26recipients%3D&amp;v=5"><img src="imagenes/delicious.gif" alt="1" width="16" height="16" border="0" /></a></div></td>
    </tr>
  </table>
</form>
sigue:...
  #2 (permalink)  
Antiguo 07/06/2011, 12:10
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

????? que quieres ?
  #3 (permalink)  
Antiguo 07/06/2011, 12:11
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

quiero saber como hacer para que solo ingresen al perfil si esta logeado?

es que no me doy cuenta como hacer o que poner en la pagina micuenta.php
  #4 (permalink)  
Antiguo 07/06/2011, 12:13
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

gracias por responder es que no se o no me doy cuenta como hacerlo, ya tengo el login y registro y funciona muy bien pero con el tema sesiones no se..
  #5 (permalink)  
Antiguo 07/06/2011, 12:15
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

bueno en cada pagina que quieras verificar empiezas con un session_start();
y despues verficas que $_SESSION['isLoged'] o la otra no importa sea difernte de null, si no es asi mandalo a login

header("Location: donde quieras")
  #6 (permalink)  
Antiguo 07/06/2011, 12:22
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

lo puse asi : <?php session_start();
$_SESSION['isLoged']= 'isLoged';

echo "<script>
location.href='login.php';
</script>";
?>

y cuando entro a micuenta.php me envia de nuevo a login?

disculpa de nuevo
  #7 (permalink)  
Antiguo 07/06/2011, 12:28
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

micuenta.php

<?php
session_start();
if ($_SESSION['isLoged'] != 'isLoged') header('location:login.php');
?>


login.php

<?php session_start();
$_SESSION['isLoged']= 'isLoged';
header("Location:micuenta.php");
?>

prueba ahora
  #8 (permalink)  
Antiguo 07/06/2011, 12:36
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

Uffff eres grande amigo genial donde te doy puntos?


Anda a mil!!!!!
Muchas gracias
  #9 (permalink)  
Antiguo 07/06/2011, 12:39
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

x nada, para eso estamos...., ahora te falta el archivo cerrar seccion !!!

<?php
session_start();
unset($_SESSION['isLoged']);
session_destroy();
header('location:login.php');

?>
  #10 (permalink)  
Antiguo 07/06/2011, 12:44
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

JAJAAJAJ AHORA SI ME PUSISTE EN UN EMBROYO ¿?¿?

Y ESTO

unset($_SESSION['isLoged']);
session_destroy();
header('location:login.php');


DONDE VA? PORQUE LO PUSE EN MICUENTA.PHP

Y ME DA ERROR PORQUE YA TENGO ESTO

<?php
session_start();
if ($_SESSION['isLoged'] != 'isLoged') header('location:login.php');
?>
  #11 (permalink)  
Antiguo 07/06/2011, 12:46
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

no !!! eso seria para el archivo donde cierras la seccion, es el tipico cerrar seccion de los sitios
crea otro archivo y llamale logout.php
y pon lo que te di ultimo
  #12 (permalink)  
Antiguo 07/06/2011, 12:47
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

solo queria que tuvieras el ejemplo completo
  #13 (permalink)  
Antiguo 07/06/2011, 12:48
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

Me has salvado el sitio web... Esta casi decidido a dejarlo por el camino....

Sinceramente muchas gracias!!!
  #14 (permalink)  
Antiguo 07/06/2011, 12:50
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

eso es mejor que los puntos del karma, cuando sepas algo ayuda a los demás como mismo alguien hizo contigo..., yo le debo mucho a este sitio
  #15 (permalink)  
Antiguo 07/06/2011, 13:43
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: Sesiones

sabes tengo un problema no cierra la sesion y cierra no me abre nuevamente el login?

disculpa la molestia
  #16 (permalink)  
Antiguo 07/06/2011, 13:48
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

pasanos el contenido de el archivo que cierra las secciones tal y como lo tienes ahora
  #17 (permalink)  
Antiguo 07/06/2011, 13:50
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

el que tu me has dado

salir.php

<?php
session_start();
unset($_SESSION['isLoged']);
session_destroy();
header('location:login.php');

?>
  #18 (permalink)  
Antiguo 07/06/2011, 13:54
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

y estás seguro q eso no destruye la session ????, pq estoy seguro que si lo hace y te rediecciona a login....

pasame los 3 archivos,
login, cerrar y el otro
  #19 (permalink)  
Antiguo 07/06/2011, 13:55
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

tengo que poner algo en login.php u las demas paginas?
  #20 (permalink)  
Antiguo 07/06/2011, 13:56
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

Te paso : 1- login.php

Código PHP:
Ver original
  1. <?php session_start();
  2. $_SESSION['isLoged']= 'isLoged';
  3. header("Location:micuenta.php");
  4. ?>
  5. <?php
  6.  
  7. /*
  8. This script was downloaded at:
  9. LightPHPScripts.com
  10. Please support us by visiting
  11. out website and letting people
  12. know of it.
  13. Produced under: LGPL
  14. */
  15.  
  16. /* Start session */
  17. if($startSession == TRUE){ session_start();}
  18.  
  19. /* Config file */
  20. include('config.php');
  21.  
  22. /* Check for submition */
  23. if($_POST['submitID'] == 1){
  24.    
  25.     /* Connect to database */
  26.     if($connectDatabase == TRUE){$action=TRUE;include('connect.php');}
  27.        
  28.     /* sanitize and check info */
  29.     $userName = mysql_real_escape_string($_POST['userName'],$dbc);
  30.     $password = mysql_real_escape_string($_POST['password'],$dbc);
  31.    
  32.     if($userName == NULL) { $message = 'Por favor ingrese nombre de usuario.';}
  33.     if($message == NULL && $password == NULL){ $message = 'Por favor, introduzca la Clave.';}
  34.    
  35.     if($message == NULL)
  36.     {              
  37.         $userQuery = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM " . $tableName .
  38.         " WHERE `" . $userNameField . "`='$userName' AND `" . $userPasswordField . "`='$password'"));      
  39.        
  40.         /* If usercount is more than 0 -> ok */
  41.         if($userQuery[0] > 0){
  42.             /* Disconnect from database */
  43.             if($connectDatabase == TRUE){$action=FALSE;include('connect.php');}
  44.    
  45.             $_SESSION['isLoged'] = 'yes';
  46.             $_SESSION['userName'] = $userName;
  47.            
  48.             /* add cookies ?*/
  49.             /* expire in 1 hour */
  50.             if($useCookies == TRUE)
  51.             {
  52.                 setcookie("isLoged", 'yes', time()+logedInFor, "/", ".$domainName", 1);
  53.                 setcookie("userName", $userName, time()+logedInFor, "/", ".$domainName", 1);
  54.             }
  55.  
  56.             /* Redirect to login page */
  57.             header("Location: $loginPage");
  58.             exit();
  59.         } else {
  60.             $message = 'No válido nombre de usuario y / o Clave!';
  61.         }
  62.     }
  63.     /* Disconnect from database */
  64.     if($connectDatabase == TRUE){$action=FALSE;include('connect.php');}
  65. }
  66. ?><style type="text/css">
  67. <!--
  68. #Layer8 {
  69.     position:absolute;
  70.     left:510px;
  71.     top:220px;
  72.     width:100px;
  73.     height:300px;
  74.     z-index:1;
  75.     font-family: Arial, Helvetica, sans-serif;
  76.     font-size: 14px;
  77.     color: #0099CC;
  78. }
  79. #Layer9 {
  80.     position:absolute;
  81.     left:200px;
  82.     top:500px;
  83.     width:900px;
  84.     height:50px;
  85.     z-index:1;
  86.     font-family: Arial, Helvetica, sans-serif;
  87.     font-size: 12px;
  88.     color: #0099FF;
  89.     border-top-width: thin;
  90.     border-top-style: dashed;
  91.     border-top-color: #3399FF;
  92. }
  93. #Layer10 {
  94.     position:absolute;
  95.     left:34px;
  96.     top:257px;
  97.     width:49px;
  98.     height:18px;
  99.     z-index:1;
  100. }
  101. -->
  102. </style>
  103. <div id="Layer8">
  104. <!--
  105. /*
  106. This script was downloaded at:
  107. LightPHPScripts.com
  108. Please support us by visiting
  109. out website and letting people
  110. know of it.
  111. Produced under: LGPL
  112. */
  113. -->
  114. <?php
  115.  
  116. /* Display error messages */
  117. if($message != NULL){?>
  118. <div align="center">
  119.   <table width="250"  border="0" cellpadding="3" cellspacing="0" bgcolor="#FFCCCC">
  120.     <tr>
  121.       <td><div align="center"><strong><font color="#FF0000"><?=$message;?></font></strong></div></td>
  122.     </tr>
  123.   </table>
  124.   <?php } ?><form action="<? echo $_SERVER['PHP_SELF'];?>" method="post" name="login" id="login" style="display:inline;">
  125.   <table width="250" align="center" cellpadding="5" cellspacing="0">
  126.     <tr bgcolor="#99CC99">
  127.       <td colspan="2" bgcolor="B3D9EC"><div align="center"><font color="#FFFFFF"><strong>Validaci&oacute;n de Usuario y Clave:</strong></font></div></td>
  128.     </tr>
  129.     <tr>
  130.       <td width="47%"><strong>Usuario:</strong></td>
  131.       <td width="53%"><input name="userName" type="text" id="userName"></td>
  132.     </tr>
  133.     <tr>
  134.       <td><strong>Clave:</strong></td>
  135.       <td><input name="password" type="password" id="password"></td>
  136.     </tr>
  137.     <tr>
  138.       <td colspan="2"><div align="center"><font face="Georgia, Times New Roman, Times, serif"><strong>
  139.           <input name="Submit" type="submit" id="Submit" value="Ingresar"> <a href="register.php">Registrarme</a>
  140.           <input name="submitID" type="hidden" id="submitID" value="1">
  141. </strong></font> </div></td>
  142.     </tr>
  143.     <tr>
  144.       <td colspan="2"><div align="center">Compartilo <a href="http://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fofertasdiarias.net%2F&amp;t="><img src="imagenes/facebook.gif" alt="2" width="16" height="16" border="0" /></a> <a href="https://www.google.com/accounts/ServiceLogin?passive=1209600&amp;continue=https%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26bkmk%3Dhttp%253A%252F%252Fofertasdiarias.net%252F&amp;hl=es"><img src="imagenes/google.gif" alt="3" width="16" height="16" border="0" /></a> <a href="http://twitter.com/?status=Hoy - Ofertasdiarias Comprar y vender http%3A//ofertasdiarias.net/"><img src="twitter.gif" alt="4" width="16" height="16" border="0" /></a> <a href="https://secure.delicious.com/login?jump=http%3A%2F%2Fwww.delicious.com%2Fsave%3Furl%3Dhttp%253A%252F%252Fofertasdiarias.net%252F%26title%3DHoy%2520-%2520Ofertasdiarias%2520Comprar%2520y%2520vender%26notes%3D%26tags%3D%26noui%3Dno%26jump%3Dyes%26time%3D1306946854%26share%3Dyes%26recipients%3D&amp;v=5"><img src="imagenes/delicious.gif" alt="1" width="16" height="16" border="0" /></a></div></td>
  145.     </tr>
  146.   </table>
  147. </form>
  148. </div>
  149.  
  150. </div>
  151. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  152. <head>
  153. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  154. <link href="css/estilos.css" rel="stylesheet" type="text/css" />
  155. <title> OfertasDiarias.net en Español</title>
  156. <style type="text/css">
  157. <!--
  158. #Layer2 {
  159.     position:absolute;
  160.     left:200px;
  161.     top:21px;
  162.     width:60px;
  163.     height:42px;
  164.     z-index:1;
  165. }
  166. #Layer3 {
  167.     position:absolute;
  168.     left:818px;
  169.     top:7px;
  170.     width:300px;
  171.     height:42px;
  172.     z-index:1;
  173.     font-family: Arial, Helvetica, sans-serif;
  174.     font-size: 14px;
  175.     color: #0099CC;
  176. }
  177. #Layer4 {
  178.     position:absolute;
  179.     left:550px;
  180.     top:50px;
  181.     width:350px;
  182.     height:50px;
  183.     z-index:1;
  184.     font-family: Arial, Helvetica, sans-serif;
  185.     font-size: 14px;
  186.     font-weight: normal;
  187.     color: #0099CC;
  188. }
  189. #Layer5 {
  190.     position:absolute;
  191.     left:900px;
  192.     top:53px;
  193.     width:50px;
  194.     height:25px;
  195.     z-index:1;
  196.     font-family: Arial, Helvetica, sans-serif;
  197.     font-size: 14px;
  198.     color: #0066FF;
  199. }
  200. #Layer6 {
  201.     position:absolute;
  202.     left:500px;
  203.     top:33px;
  204.     width:600px;
  205.     height:60px;
  206.     z-index:1;
  207.     background-color: #95E3F4;
  208.     border-top-width: thin;
  209.     border-top-style: dashed;
  210.     border-top-color: #00CCCC;
  211. }
  212. #Layer7 {
  213.     position:absolute;
  214.     left:818px;
  215.     top:98px;
  216.     width:300px;
  217.     height:25px;
  218.     z-index:1;
  219.     font-family: Arial, Helvetica, sans-serif;
  220.     font-size: 14px;
  221.     color: #0099CC;
  222. }
  223. -->
  224. </style>
  225. </head>
  226. <body>
  227. <div id="Layer9"></div>
  228. <div id="Layer7"> &iquest;Te Gusta Ofertas ?  Compartilo <a href="http://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fofertasdiarias.net%2F&amp;t="><img src="imagenes/facebook.gif" width="16" height="16" border="0" /></a> <a href="https://www.google.com/accounts/ServiceLogin?passive=1209600&amp;continue=https%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26bkmk%3Dhttp%253A%252F%252Fofertasdiarias.net%252F&amp;hl=es"><img src="imagenes/google.gif" width="16" height="16" border="0" /></a> <a href="http://twitter.com/?status=Hoy - Ofertasdiarias Comprar y vender http%3A//ofertasdiarias.net/"><img src="twitter.gif" width="16" height="16" border="0" /></a> <a href="https://secure.delicious.com/login?jump=http%3A%2F%2Fwww.delicious.com%2Fsave%3Furl%3Dhttp%253A%252F%252Fofertasdiarias.net%252F%26title%3DHoy%2520-%2520Ofertasdiarias%2520Comprar%2520y%2520vender%26notes%3D%26tags%3D%26noui%3Dno%26jump%3Dyes%26time%3D1306946854%26share%3Dyes%26recipients%3D&amp;v=5"><img src="imagenes/delicious.gif" width="16" height="16" border="0" /></a> </div>
  229. <div id="Layer6"></div>
  230. <div id="Layer5"><a href="login.php">Entrar</a></div>
  231. <div id="Layer4">
  232.   <form id="form1" name="form1" method="post" action="buscar.php">
  233.     <input name="textfield" type="text" size="40" />
  234.     <input type="submit" name="Submit" value="Buscar" />
  235.   </form>
  236. </div>
  237. <div id="Layer3"> <a href="index.php">Inicio</a> | <a href="register.php">Regístrate</a> | <a href="micuenta.php">Mi Cuenta</a> | <a href="ayuda.php">Ayuda</a> | <a href="mapa.php">Mapa</a> </div>
  238. <div id="Layer2"><a href="index.php"><img src="imagenes/logo.png" width="300" height="80" border="0" /></a></div>
  239. </body>
  240. </html>
  #21 (permalink)  
Antiguo 07/06/2011, 13:57
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

2- logoff.php

Código PHP:
Ver original
  1. <?php
  2. /*
  3. This script was downloaded at:
  4. LightPHPScripts.com
  5. Please support us by visiting
  6. out website and letting people
  7. know of it.
  8. Produced under: LGPL
  9. */
  10.  
  11. /* Config file */
  12. include('config.php');
  13.  
  14. /* Start session */
  15.  
  16. if($useCookies == TRUE)
  17. {
  18.     /* Remove cookies */
  19.     setcookie("isLoged", '' ,time()-1600, "/", ".$domainName", 1);
  20.     setcookie("userName",'' , time()-1600, "/", ".$domainName", 1);
  21. }
  22.  
  23. /* Blank out sessions */
  24. $_SESSION['isLoged'] = NULL;
  25. $_SESSION['userName'] = NULL;
  26.  
  27. /* Unset all of the session variables */
  28. $_SESSION = array();
  29.  
  30. /* Destory this session */
  31.  
  32. /* Rdirect to logout page */
  33. header("Location: $logoutPage");
  34. exit();
  35. ?>
  #22 (permalink)  
Antiguo 07/06/2011, 13:57
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

3- micuenta.php

Código PHP:
Ver original
  1. <?php
  2. if ($_SESSION['isLoged'] != 'isLoged') header('location:login.php');
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  8. <title>Documento sin t&iacute;tulo</title>
  9. <style type="text/css">
  10. <!--
  11. #Layer1 {
  12.     position:absolute;
  13.     left:255px;
  14.     top:72px;
  15.     width:92px;
  16.     height:169px;
  17.     z-index:1;
  18. }
  19. -->
  20. </style>
  21. </head>
  22. <body>
  23. <div id="Layer1">
  24.   <p>&nbsp;</p>
  25. </div>
  26. </body>
  27. </html>
  #23 (permalink)  
Antiguo 07/06/2011, 13:58
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

y el 4 - config.php

Código PHP:
Ver original
  1. <?php
  2. /*
  3. This script was downloaded at:
  4. LightPHPScripts.com
  5. Please support us by visiting
  6. out website and letting people
  7. know of it.
  8. Produced under: LGPL
  9. */
  10.  
  11. /* Main Options */
  12. //----------------
  13.  
  14. /* Which page user goes to after logoss */
  15. $logoutPage = 'index.php';
  16.  
  17. /* Secure page to redirect to after login */
  18. $loginPage = 'micuenta.php';
  19. /* Secure page to redirect to after register */
  20. $registerPage = 'registrado.php';
  21.  
  22. /* Start session? Set this to false, if
  23. you are already starting the session elsewhere
  24. */
  25. $startSession = TRUE;
  26.  
  27. /* Use Cookies with sessions*/
  28. $useCookies = TRUE;
  29.  
  30. /* Stay loged in for? -> cookies */
  31. /* in seconds:
  32. 3600 ->  1 hr, 86400 -> 1 day
  33. 604800 -> 1 week, 2419200 -> 1 month
  34. 29030400 -> 1 year
  35. */
  36. $logedInFor = 2419200;
  37.  
  38. /* Domain name -> cookies */
  39. $domainName = 'ofertasdiarias.net';
  40.  
  41. /*
  42. Notes: Please note that using sessions,
  43. will store a cookie with the ID on userside.
  44. To make this work for users without cookies,
  45. propagate the ID through the URLS
  46. in this manner:
  47. nextpage.php?<?php echo htmlspecialchars(SID); ?>
  48. */
  49.  
  50. /* Connect to database? Set to false, if you
  51. are already conneted */
  52. $connectDatabase = TRUE;
  53.  
  54. /* Database Info */
  55. $databaseUserName = 'root';
  56. $databaseUserPassword = 'dahiana';
  57. $databaseHostName = 'localhost';
  58. $databaseName = 'diarias';
  59.  
  60. /* Table Info */
  61. $tableName = 'userlist';
  62. $userNameField = 'userName';
  63. $userPasswordField = 'UserPassword';
  64.  
  65. /** SEC 334 **/
  66. ?>
  #24 (permalink)  
Antiguo 07/06/2011, 13:59
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

en login creas la session, en los demas preguntas si existe y en cerrar la eliminas, es asi el proceso, lo que pasa es que como estas redireccionando de cerrar a login siempre te crea la session, tienes que redireccionar

te das cuenta d lo que está pasando ???
en login siempre creas la session y si de cerrar pasa a login de nuevo, pues se vuelve a crear
  #25 (permalink)  
Antiguo 07/06/2011, 14:00
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

viste lo que te explique ?
  #26 (permalink)  
Antiguo 07/06/2011, 14:01
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

Me puedes mostrar un ejemplo?
  #27 (permalink)  
Antiguo 07/06/2011, 14:03
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

mira crea archivo1

<?php
session_start();
if ($_SESSION['isLoged'] != NULL)
{
echo "soy administrador";

}
else
header('location:login.php');
?>


login

session_start();
$_SESSION['isLoged'] = "algo";


cerrar

session_start();
unset($_SESSION['isLoged']);
session_destroy();
header('location:archivo1.php');

Última edición por iviamontes; 07/06/2011 a las 14:05 Razón: error
  #28 (permalink)  
Antiguo 07/06/2011, 14:14
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

perdona pero aun no anda amigo...

debe ser otro problema el cual no me doy cuenta...
  #29 (permalink)  
Antiguo 07/06/2011, 14:14
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: Sesiones

rectifico para que veas mejor

mira crea archivo1

<?php
session_start();
if ($_SESSION['isLoged'] != NULL)
{
echo "soy administrador";

}
else
echo "no soy nadie";
?>
  #30 (permalink)  
Antiguo 07/06/2011, 14:37
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

no amigo no aun no resuelvo el dilema igual no te preocupes ya vere

muchas gracias!!!

Etiquetas: sesiones
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

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 10:29.