...

View Full Version : session destroy



rakasv
06-15-2010, 10:58 PM
Hi i'm trying to logout from a session but the $_SESSION['user'] shows the same even if i try with another registered user

this is where i do the login (http://www.adconsulting.mx/adacosta/pruebas_php/login.php)

username1: Alex password:adacosta
username2:Raquel password adacosta01

my logout.php is like this:


<?php
//empieza sesion
session_start();

//nos aseguramos que la variable esté registrada
if(session_is_registered('usuario')){

//la variable de sesion esta registrada, procedemos a destriur la sesion
session_unset();
session_destroy();

}
else{


echo"no se puede terminar la sesión correctamente"
}
?>

i can't find out what could be wrong

thanks a lot

Brandoe85
06-15-2010, 11:27 PM
Do you need to clear all sessions? Check out the user comments for it:
http://us3.php.net/session_unset

Else just unset the session you need to clear:
unset($_SESSION['yourVar']);

Good luck

rakasv
06-15-2010, 11:53 PM
thanks a lot i'll try that =)

rakasv
06-16-2010, 03:25 PM
i made the user name change but i still can´t make the logout button work....

this is what i got:


<?php

//start the session
session_start();

//check to make sure the session variable is registered
if(session_is_registered('usuario')){

//the session variable is registered, the user is allowed to see anything that follows

$id=session_id();
echo "Bienvenido,".$_SESSION['usuario']." Sigues Dentro yuju!!!, tu id de sesion es:".$id;

}
else{

//the session variable isn't registered, send them back to the login page
header( "Location: http://www.adconsulting.mx/adacosta/pruebas_php/login.php" );
}
echo"
<form>
<input type=\"submit\" value=\"Logout\" action=\"logout.php\" target=\"login.php\">
</form>
";
?>

and the logout.php:


<?php
session_start();
$_SESSION = array();
session_destroy();
session_regenerate_id();
header( "Location: login.php" );
?>

thanks!

rakasv
06-16-2010, 03:45 PM
ok ok!! i found it ... i was writing the form attributes to the <input type> tag... never mind thank anyway!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum