You are on page 1of 4

<html> <head><title>Prctica 24</title> <style type="text/css"> #yellow { background-color: #FFFF00; } body { width: 320px; margin: 0 auto; margin-top: 20px;

margin-bottom: 30px; } table, th, td { border: 1px white inset; } </style></head> <body> <table><tr> <td colspan="2" id="yellow"><center> <b>Informacin de la sesin</b></center></td> </tr> <tr> <td id="yellow">ID</td><td> <?php $a = session_id(); if(empty($a)) { echo "No hay sesion activa <a href='crear.php'>Crear nueva</a>"; } else { echo session_id(); } ?> </td> </tr> <tr> <td id="yellow">Nmero de accesos</td><td> <?php if (!empty($a)) { if ( isset ($_SESSION['cont'])) { echo "Visitas: ".++$_SESSION['cont']; } else { $_SESSION['cont']=0; echo "Visitas: ".++$_SESSION['cont']; } } else { echo "No hay visitas."; } ?> </td> </tr> <tr> <td id="yellow">Nombre actual</td><td> <?php if (!empty($a)) { echo session_name(); } else { echo "No existe"; }?></td></tr><tr> <td id="yellow">Nombre anterior</td><td> <?php if ( isset ($nombreant) ) { echo $nombreant; } else { echo "No existe"; } ?></td></tr></table> <div> <center><a href="practica24.php">Actualizar</a> | <a href="cerrar.php">Cerrar sesin</a></center> </div> </body> </html>

<html lang="es"> <head><title>Crear sesin</title></head> <body> <?php if (isset($_POST['nombre'])){ $nom = $_POST['nombre']; session_name($nom); session_start(); $_SESSION['st']=1; header("Location: practica24.php"); } else { ?> <h1>Control de sesiones</h1><table align="center"> <form action="crear.php" method="POST"/><tr><td>Nombre de sesin:</td><td><input type="text" name="nombre"/></td></tr></form> <?php } ?> </body> </html>

<?php session_start(); ?> <html> <header> <title>Cerrar sesin</title> </header> <body> <?php session_start(); $nombreant = session_name(); if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]); } session_unset(); $_SESSION = array(); session_destroy(); ?> <h1>Sesin cerrada con xito</h2> <p>Su sesin anterior llamada como <?php echo $nombreant; ?> ha finalizado correctamente.</p> <a href="practica24.php">Regresar al inicio</a> </body> </html>

You might also like