php - why session data not being destroy? -
i have simple php simple scripts. 1 display login user, , other 1 log out. these code fragments larger file. anyway, first executed login script , enter user name, user name showed fine. next executed logout. if entered login page again, expected login_user empty, not. older login_user name still there. if clear cache , bring login page again, login_user gone. how clear session data good? here login.php
<?php session_start(); $_session['myerror']="xxx"; displayloginuser(); function displayloginuser() { if (isset ($_session['login_user'])) { echo $_session['login_user']; } } // end displayloginuser ?>
here logout.php
<?php // note none of statements below seem clear login_user $_session['login_user'] = " "; unset ($_session['login_user']); session_destroy(); header("location: library.php"); ?>
try this:
session_start(); $_session = array(); session_destroy();
will destroy session , variables no need unset()
or else
Comments
Post a Comment