php - Trouble logging out / destroying session -
php - Trouble logging out / destroying session -
im having problem destroying session on little test-side made.
i can log in code_login.php file, , header() other page, login required. when log out, can go page though logged out.
(session_start() @ top of pages)
this login code:
$res = $db->query($sql); $num = $res->num_rows; if ($num == 1) { $_session['user'] = array( 'username' => $username; ); }
here logout:
session_start(); $_session = array(); session_destroy(); header('location: index.php?loggedout');
this top of page login required
session_start(); if (isset($_session['user'])) { require stuff; } else { header('location: index.php?loginneeded'); }
but still able go loginrequired page, after logging in.
session_start();
is inserted on every page set or unset session reading session
data
php session logout
Comments
Post a Comment