Ver Mensaje Individual
  #5 (permalink)  
Antiguo 10/06/2013, 14:30
Avatar de Ilidam
Ilidam
 
Fecha de Ingreso: julio-2009
Ubicación: Veracruz
Mensajes: 108
Antigüedad: 14 años, 9 meses
Puntos: 0
Respuesta: Cerrar sesion php

Código PHP:
Ver original
  1. <?
  2.     require_once("cierra.php");
  3.  
  4.     $sesion = new sesion();
  5.     $car = $sesion->get("carrito");
  6.     if( $car == false )
  7.     {
  8.         header("../index.html");
  9.     }
  10.     else
  11.     {
  12.         $sesion->termina_sesion();
  13.                 header("./busca.php");
  14.         }
  15. ?>
  16.  
  17. cierra.php
  18.  
  19. <?php
  20. error_reporting(E_ERROR);
  21. ?>
  22. <?php
  23. class sesion {
  24.   function __construct() {
  25.      session_start();
  26.   }
  27.   public function set($nombre, $valor) {
  28.      $_SESSION [$nombre] = $valor;
  29.   }
  30.   public function get($nombre) {
  31.      if (isset ( $_SESSION [$nombre] )) {
  32.         return $_SESSION [$nombre];
  33.      } else {
  34.          return false;
  35.      }
  36.   }
  37.   public function elimina_variable($nombre) {
  38.       unset ( $_SESSION [$nombre] );
  39.        unset ( $_SESSION ["carrito"] );
  40.        session_destroy ();
  41.   }
  42.  
  43. }
  44. ?>


Asta aki todo bien y nose xk no me hace lo k tu dices ya me desespere