Foros del Web » Programando para Internet » PHP »

Sesiones

Estas en el tema de Sesiones en el foro de PHP en Foros del Web. achivo1.php <?php session_start(); if ($_SESSION['isLoged'] != NULL) { echo "soy administrador"; } else header('location:login.php'); ?> login.php <?php session_start(); $_SESSION['isLoged'] = "algo"; header('location:archivo1.php'); ?> cerrar.php <?php ...

  #31 (permalink)  
Antiguo 07/06/2011, 14: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

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

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


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

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

esto no te funciona ???? seguro ?
  #32 (permalink)  
Antiguo 07/06/2011, 14:55
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

es un problema de cookies jejeeje pero aun no lo hago funcionar
  #33 (permalink)  
Antiguo 07/06/2011, 15:01
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

pero hazme caso crea esos 3 archivos nuevos y dime
  #34 (permalink)  
Antiguo 07/06/2011, 15:07
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

el login y achivo1.php andan el cerrar.php me pone ( ¡Objeto no encontrado!

El enlace requerido no ha sido localizado en este servidor. Si usted proporcionó el enlace de manera manual le solicitamos que por favor revise los datos e intentelo de nuevo.

Por favor contacte con el webmaster en caso de que usted crea que existe un error en el servidor.
Error 404
localhost
07/06/2011 18:06:06
Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 )
  #35 (permalink)  
Antiguo 07/06/2011, 15:10
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

ahora en los tres me pone soy el administrador
  #36 (permalink)  
Antiguo 07/06/2011, 16:43
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

pq no estas cerrando la seccion, fijate en los nombre de los archivos, todos hacen header para archivo1.php
revisa los nombre de los archivos, y cookies y sessiones son cosas diferents, se usan para lo mismo, pero no tienen nada que ver entre ellas
  #37 (permalink)  
Antiguo 07/06/2011, 17:15
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

me los puedes mostrar como hacer en los codigos que yo te mostre hoy?

porque no me doy cuenta como se hace...
  #38 (permalink)  
Antiguo 07/06/2011, 18:34
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

paso estos script por si me pueden ayudar :

index.php

Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <link href="css/estilos.css" rel="stylesheet" type="text/css" />
  6. <title> OfertasDiarias.net en Español</title>
  7. <style type="text/css">
  8. <!--
  9. #Layer2 {
  10.     position:absolute;
  11.     left:200px;
  12.     top:21px;
  13.     width:60px;
  14.     height:42px;
  15.     z-index:1;
  16. }
  17. #Layer3 {
  18.     position:absolute;
  19.     left:818px;
  20.     top:7px;
  21.     width:300px;
  22.     height:42px;
  23.     z-index:1;
  24.     font-family: Arial, Helvetica, sans-serif;
  25.     font-size: 14px;
  26.     color: #0099CC;
  27. }
  28. #Layer4 {
  29.     position:absolute;
  30.     left:550px;
  31.     top:50px;
  32.     width:350px;
  33.     height:50px;
  34.     z-index:1;
  35.     font-family: Arial, Helvetica, sans-serif;
  36.     font-size: 14px;
  37.     font-weight: normal;
  38.     color: #0099CC;
  39. }
  40. #Layer5 {
  41.     position:absolute;
  42.     left:900px;
  43.     top:53px;
  44.     width:50px;
  45.     height:25px;
  46.     z-index:1;
  47.     font-family: Arial, Helvetica, sans-serif;
  48.     font-size: 14px;
  49.     color: #0066FF;
  50. }
  51. #Layer6 {
  52.     position:absolute;
  53.     left:500px;
  54.     top:33px;
  55.     width:600px;
  56.     height:60px;
  57.     z-index:1;
  58.     background-color: #95E3F4;
  59.     border-top-width: thin;
  60.     border-top-style: dashed;
  61.     border-top-color: #00CCCC;
  62. }
  63. #Layer7 {
  64.     position:absolute;
  65.     left:818px;
  66.     top:98px;
  67.     width:300px;
  68.     height:25px;
  69.     z-index:1;
  70.     font-family: Arial, Helvetica, sans-serif;
  71.     font-size: 14px;
  72.     color: #FFFFFF;
  73. }
  74. #Oferta {
  75.     position:absolute;
  76.     left:408px;
  77.     top:200px;
  78.     width:476px;
  79.     height:500px;
  80.     z-index:1;
  81.     font-family: Georgia, "Times New Roman", Times, serif;
  82.     font-size: 16px;
  83.     color: #006699;
  84.     font-weight: bolder;
  85.     border: 3px solid #95E3F4;
  86.     padding: 1px;
  87. }
  88. #categorias {
  89.     position:absolute;
  90.     left:200px;
  91.     top:94px;
  92.     width:900px;
  93.     height:30px;
  94.     z-index:1;
  95.     font-family: Arial, Helvetica, sans-serif;
  96.     font-size: 12px;
  97.     color: #333333;
  98.     background-color: #0033CC;
  99. }
  100. body,td,th {
  101.     font-family: Arial, Helvetica, sans-serif;
  102.     color: #0066FF;
  103. }
  104. a:link {
  105.     color: #0066FF;
  106.     text-decoration: none;
  107. }
  108. a:visited {
  109.     text-decoration: none;
  110.     color: #0099FF;
  111. }
  112. a:hover {
  113.     text-decoration: underline;
  114.     color: #FF0000;
  115. }
  116. a:active {
  117.     text-decoration: none;
  118.     color: #0066FF;
  119. }
  120. #Layer8 {
  121.     position:absolute;
  122.     left:200px;
  123.     top:125px;
  124.     width:600px;
  125.     height:25px;
  126.     z-index:1;
  127.     color: #FF6600;
  128. }
  129. #linea {
  130.     position:absolute;
  131.     left:850px;
  132.     top:194px;
  133.     width:2px;
  134.     height:600px;
  135.     z-index:1;
  136.     background-color: #66CCFF;
  137. }
  138. #fin {
  139.     position:absolute;
  140.     left:200px;
  141.     top:900px;
  142.     width:900px;
  143.     height:100px;
  144.     z-index:1;
  145.     font-family: Arial, Helvetica, sans-serif;
  146.     font-size: 14px;
  147.     color: #FFFFFF;
  148.     background-color: #666666;
  149.     text-align: left;
  150.     vertical-align: bottom;
  151. }
  152. #termina {
  153.     position:absolute;
  154.     left:0px;
  155.     top:1000px;
  156.     width:60px;
  157.     height:27px;
  158.     z-index:1;
  159.     font-family: Arial, Helvetica, sans-serif;
  160.     font-size: 14px;
  161.     color: #FFFFFF;
  162.     clip: rect(auto,auto,auto,auto);
  163. }
  164. #herramientas {
  165.     position:absolute;
  166.     left:205px;
  167.     top:186px;
  168.     width:200px;
  169.     height:300px;
  170.     z-index:1;
  171. }
  172. .Estilo1 {
  173.     font-size: 16px;
  174.     color: #0066FF;
  175. }
  176. -->
  177. </style>
  178. </head>
  179. <body>
  180. <div class="Estilo1" id="herramientas">
  181.   <p><img src="subscribe-pic2.jpg" width="200" height="126" /></p>
  182.   <p><img src="subscribe-pic1.jpg" width="200" height="126" /></p>
  183.   <p><img src="subscribe-pic3.jpg" width="200" height="126" /></p>
  184. </div>
  185. <div id="termina">fin</div>
  186. <div id="fin">
  187.   <ul>
  188.     <li>Términos y Condiciones </li>
  189.     <li>Ayuda</li>
  190.     <li>Contactanos</li>
  191.     <li>FAQ</li>
  192.   </ul>
  193. </div>
  194. <div id="Layer8"><a href="ofertasdehoy.php">Ofertas del día</a> | <a href="ofertasrecientes.php">Ofertas Recientes</a> | <a href="comofunciona.php">¿Cómo Funciona?</a> | <a href="ciudades.php">Agregue su Oferta</a> | </div>
  195. <div id="categorias"><a href="anuncios/Ofertasdeldia.php"></a> </div>
  196. <div id="Oferta">
  197. </div>
  198. <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>
  199. <div id="Layer6"></div>
  200. <div id="Layer5"><a href="login.php">Entrar</a></div>
  201. <div id="Layer4">
  202.   <form id="form1" name="form1" method="get" action="resultado.php">
  203.     <input name="Descripcion" type="text" id="Descripcion" size="40" />
  204.     <input type="submit" name="Submit" value="Buscar" />
  205.   </form>
  206. </div>
  207. <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>
  208. <div id="Layer2"><a href="index.php"><img src="imagenes/logo.png" width="300" height="80" border="0" /></a></div>
  209. <div id="Ofertanacional"></div>
  210. </body>
  211. </html>

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

2 -->>

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>
  #40 (permalink)  
Antiguo 07/06/2011, 18:35
 
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><a href="logoff.php">salir</a></p>
  25. </div>
  26. </body>
  27. </html>
  #41 (permalink)  
Antiguo 07/06/2011, 18:36
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

4 --->>

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()-3600,"/", ".$domainName", 1);
  20.     setcookie("userName",'', time()-3600,"/", ".$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. ?>
  #42 (permalink)  
Antiguo 07/06/2011, 18:36
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

5 ---->>

config.php

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

y 6 ----->>>

connect.php

Código PHP:
Ver original
  1. <?php
  2.  
  3. /*
  4. This script was downloaded at:
  5. LightPHPScripts.com
  6. Please support us by visiting
  7. out website and letting people
  8. know of it.
  9. Produced under: LGPL
  10. */
  11.  
  12. /* Are we opening a connection, or closing it? */
  13. if($action == TRUE)
  14. {
  15.     $dbc = mysql_connect ($databaseHostName, $databaseUserName, $databaseUserPassword);
  16.     mysql_select_db($databaseName,$dbc);   
  17. } else {
  18.     mysql_close($dbc);
  19. }
  20. ?>
  #44 (permalink)  
Antiguo 07/06/2011, 18:39
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

quiero saber si alguien me puede ayudar a cerrar la sesion? es que yo no me doy cuenta como hacerlo.. porque ya lo hago en el logoff.php pero no cierra la misma...

si alguien me puede ayudar

Muchas gracias
  #45 (permalink)  
Antiguo 08/06/2011, 07:23
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

aca te hice un ejemplo completo

crea estos 3 archivos...

miembros.php
<?php
session_start();
if (@$_SESSION['login'] != NULL) {
echo "administrador<br>";
echo '<a href="logout.php">cerrar</a>';
}

else {
echo "no eres administrador<br>";
echo '<a href="login.php">login</a>';
}
?>


----- login.php
<?php
session_start();

if (isset($_POST['submit']) )
{
if ($_POST['nombre'] == "") echo "falta el nombre<br>";
else $_SESSION['login'] = $_POST['nombre'];
}

if (@$_SESSION['login'] != NULL) {
echo 'ya estas logeado<br>'.$_SESSION['login'].'<br>
<a href="miembros.php">miembros</a> <br>
<a href="logout.php">cerrar</a> ';
}
else
{
?>
no estas logeado
<form action="" method="post">
usuario<input name="nombre" type="text"><br>
<input name="submit" type="submit">
</form>
<?php } ?>


logout.php
<?php
session_start();
if (@$_SESSION['login'] != NULL) {
echo "cerramos session ".$_SESSION['login']."<br>";
;
unset($_SESSION['login']);
session_destroy();
}
else {echo "no tienes seccion creada<br>";}
?>
<a href="miembros.php">miembros</a>
  #46 (permalink)  
Antiguo 09/06/2011, 14:00
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

amigo tu ejemplo anda de maravillas pero tengo que adaptarlo a miis script y sucede lo mismo debe ser algo de el codigo de config.php

Código PHP:
Ver original
  1. <?php
  2. /*
  3. */
  4.  
  5. /* Main Options */
  6. //----------------
  7.  
  8. /* Which page user goes to after logoss */
  9. $logoutPage = 'index.php';
  10.  
  11. /* Secure page to redirect to after login */
  12. $loginPage = 'login.php';
  13. /* Secure page to redirect to after register */
  14. $registerPage = 'registrado.php';
  15.  
  16. /* Start session? Set this to false, if
  17. you are already starting the session elsewhere
  18. */
  19. $startSession = TRUE;
  20.  
  21. /* Use Cookies with sessions*/
  22. $useCookies = TRUE;
  23.  
  24. /* Stay loged in for? -> cookies */
  25. /* in seconds:
  26. 3600 ->  1 hr, 86400 -> 1 day
  27. 604800 -> 1 week, 2419200 -> 1 month
  28. 29030400 -> 1 year
  29. */
  30. $logedInFor = 86400;
  31.  
  32. /* Domain name -> cookies */
  33. $domainName = 'localhost';
  34.  
  35. /*
  36. Notes: Please note that using sessions,
  37. will store a cookie with the ID on userside.
  38. To make this work for users without cookies,
  39. propagate the ID through the URLS
  40. in this manner:
  41. nextpage.php?<?php echo htmlspecialchars(SID); ?>
  42. */
  43.  
  44. /* Connect to database? Set to false, if you
  45. are already conneted */
  46. $connectDatabase = TRUE;
  47.  
  48. /* Database Info */
  49. $databaseUserName = 'root';
  50. $databaseUserPassword = 'dahiana';
  51. $databaseHostName = 'localhost';
  52. $databaseName = 'diarias';
  53.  
  54. /* Table Info */
  55. $tableName = 'userlist';
  56. $userNameField = 'userName';
  57. $userPasswordField = 'UserPassword';
  58.  
  59. /** SEC 334 **/
  60. ?>
  #47 (permalink)  
Antiguo 09/06/2011, 14:40
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

Cita:
Iniciado por ofertasdiariass Ver Mensaje
amigo tu ejemplo anda de maravillas pero tengo que adaptarlo a miis script y sucede lo mismo debe ser algo de el codigo de config.php

Código PHP:
Ver original
  1. <?php
  2. /*
  3. */
  4.  
  5. /* Main Options */
  6. //----------------
  7.  
  8. /* Which page user goes to after logoss */
  9. $logoutPage = 'index.php';
  10.  
  11. /* Secure page to redirect to after login */
  12. $loginPage = 'login.php';
  13. /* Secure page to redirect to after register */
  14. $registerPage = 'registrado.php';
  15.  
  16. /* Start session? Set this to false, if
  17. you are already starting the session elsewhere
  18. */
  19. $startSession = TRUE;
  20.  
  21. /* Use Cookies with sessions*/
  22. $useCookies = TRUE;
  23.  
  24. /* Stay loged in for? -> cookies */
  25. /* in seconds:
  26. 3600 ->  1 hr, 86400 -> 1 day
  27. 604800 -> 1 week, 2419200 -> 1 month
  28. 29030400 -> 1 year
  29. */
  30. $logedInFor = 86400;
  31.  
  32. /* Domain name -> cookies */
  33. $domainName = 'localhost';
  34.  
  35. /*
  36. Notes: Please note that using sessions,
  37. will store a cookie with the ID on userside.
  38. To make this work for users without cookies,
  39. propagate the ID through the URLS
  40. in this manner:
  41. nextpage.php?<?php echo htmlspecialchars(SID); ?>
  42. */
  43.  
  44. /* Connect to database? Set to false, if you
  45. are already conneted */
  46. $connectDatabase = TRUE;
  47.  
  48. /* Database Info */
  49. $databaseUserName = 'root';
  50. $databaseUserPassword = 'dahiana';
  51. $databaseHostName = 'localhost';
  52. $databaseName = 'diarias';
  53.  
  54. /* Table Info */
  55. $tableName = 'userlist';
  56. $userNameField = 'userName';
  57. $userPasswordField = 'UserPassword';
  58.  
  59. /** SEC 334 **/
  60. ?>
lo unico que hace es darle valores a variables, tienes que poner los archivos en los que tienes problemas
  #48 (permalink)  
Antiguo 09/06/2011, 16:22
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

PONGO MI PROBLEMA HABER SI ALGUIEN SE DA CUENTA QUE SUCEDE QUE NO CIERRA SESION?

-- Estructura de tabla para la tabla `userlist`

Base de Datos
Código MySQL:
Ver original
  1. -- Base de datos: `diarias`
  2. --
  3.  
  4.  
  5. CREATE TABLE IF NOT EXISTS `userlist` (
  6.   `userId` bigint(20) NOT NULL AUTO_INCREMENT,
  7.   `userName` varchar(255) NOT NULL,
  8.   `userPassword` varchar(255) NOT NULL,
  9.   PRIMARY KEY (`userId`)
  10. ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='List of Members' AUTO_INCREMENT=15 ;

los otros articulos. :

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>

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

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. </body>
  24. </html>

SIGUE ---->>
  #50 (permalink)  
Antiguo 09/06/2011, 16:24
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

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. if($useCookies == TRUE)
  16. {
  17.     /* Remove cookies */
  18.     setcookie("isLoged", '',time()-86400,"/", ".$domainName", 1);
  19.     setcookie("userName",'', time()-86400,"/", ".$domainName", 1);
  20. }
  21.  
  22. /* Blank out sessions */
  23. $_SESSION['isLoged'] = NULL;
  24. $_SESSION['userName'] = NULL;
  25.  
  26. /* Unset all of the session variables */
  27. $_SESSION = array();
  28.  
  29. /* Destory this session */
  30. unset($_SESSION['isLoged']);
  31.  
  32.  
  33. /* Rdirect to logout page */
  34. header("Location:$logoutPage");
  35. exit();
  36. ?>

SIGUE---->>
  #51 (permalink)  
Antiguo 09/06/2011, 16:25
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

config.php

Código PHP:
Ver original
  1. <?php
  2. /*
  3. */
  4.  
  5. /* Main Options */
  6. //----------------
  7.  
  8. /* Which page user goes to after logoss */
  9. $logoutPage = 'index.php';
  10.  
  11. /* Secure page to redirect to after login */
  12. $loginPage = 'login.php';
  13. /* Secure page to redirect to after register */
  14. $registerPage = 'registrado.php';
  15.  
  16. /* Start session? Set this to false, if
  17. you are already starting the session elsewhere
  18. */
  19. $startSession = TRUE;
  20.  
  21. /* Use Cookies with sessions*/
  22. $useCookies = TRUE;
  23.  
  24. /* Stay loged in for? -> cookies */
  25. /* in seconds:
  26. 3600 ->  1 hr, 86400 -> 1 day
  27. 604800 -> 1 week, 2419200 -> 1 month
  28. 29030400 -> 1 year
  29. */
  30. $logedInFor = 86400;
  31.  
  32. /* Domain name -> cookies */
  33. $domainName = 'localhost';
  34.  
  35. /*
  36. Notes: Please note that using sessions,
  37. will store a cookie with the ID on userside.
  38. To make this work for users without cookies,
  39. propagate the ID through the URLS
  40. in this manner:
  41. nextpage.php?<?php echo htmlspecialchars(SID); ?>
  42. */
  43.  
  44. /* Connect to database? Set to false, if you
  45. are already conneted */
  46. $connectDatabase = TRUE;
  47.  
  48. /* Database Info */
  49. $databaseUserName = 'root';
  50. $databaseUserPassword = 'dahiana';
  51. $databaseHostName = 'localhost';
  52. $databaseName = 'diarias';
  53.  
  54. /* Table Info */
  55. $tableName = 'userlist';
  56. $userNameField = 'userName';
  57. $userPasswordField = 'UserPassword';
  58.  
  59. /** SEC 334 **/
  60. ?>

SIGUE--->>
  #52 (permalink)  
Antiguo 09/06/2011, 16:26
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

connect.php

Código PHP:
Ver original
  1. <?php
  2.  
  3. /*
  4. This script was downloaded at:
  5. LightPHPScripts.com
  6. Please support us by visiting
  7. out website and letting people
  8. know of it.
  9. Produced under: LGPL
  10. */
  11.  
  12. /* Are we opening a connection, or closing it? */
  13. if($action == TRUE)
  14. {
  15.     $dbc = mysql_connect ($databaseHostName, $databaseUserName, $databaseUserPassword);
  16.     mysql_select_db($databaseName,$dbc);   
  17. } else {
  18.     mysql_close($dbc);
  19. }
  20. ?>

Alguno que lo haga y a ver si se da cuenta lo que digo de que no cierra la sesion? porque yo no logro darme cuenta
  #53 (permalink)  
Antiguo 09/06/2011, 16: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

en tu logoff deja nada mas el codigo de detruir session
  #54 (permalink)  
Antiguo 09/06/2011, 16:38
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 12 años, 11 meses
Puntos: 4
Respuesta: Sesiones

no nada sigue todo igual ? tu lo haz probado?

yo no puedo lograrlo no se?
  #55 (permalink)  
Antiguo 09/06/2011, 16:44
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 no te es mejor modificar lo que te di ?, a lo mejor te es mas facil que no intentar al revés...
mañana seguimos...
  #56 (permalink)  
Antiguo 12/06/2011, 16:33
 
Fecha de Ingreso: junio-2011
Mensajes: 39
Antigüedad: 12 años, 10 meses
Puntos: 2
Respuesta: Sesiones

OYE AMIGO LO PUEDE SOLUCIONAR.


mira el sitio lofertasdiarias.net

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 21:57.