hi
when i click the previous page button it was gng to logout page the sesion was not destroying when iwas using this code please help me

<?php
session_start();
session_unset($_SESSION['uname']);
session_destroy();
header ("Location: login.php");
?>

try this code:

session_start();
session_unregister('uname');
session_destroy();
header ("Location: login.php");

all you need to do to destroy a session is call

session_destroy();

you don't need to unset variables before then.

session_unregister is depreciated anyway.

if you want to remove something like the uname part of the session array just use

unset($_SESSION['uname']);

I've always just done

function destroy_sess($sessname = "all sessions")
{
	if($sessname == "all sessions")
	{
		$_SESSION = array();
	}
	else
	{
		$_SESSION[$sessname] = NULL;
		unset($_SESSION[$sessname]);
	}
}

and that works fine for everything that I do.

BTW: session_unregister() is not forward compatible with php6

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.