I'm getting frustated. Tried everything to logout users from my PHP page but it does not work the shoppingcart is still full and the user name is still there. My webpage is about a online shopping. The login works fine and I created a logout file with the following code
session_start();
session_destroy();
header('Location: login.php');
exit;
My login code is:
// get Members table
require './Model/Members.php';
$memberTable = new Members();
if (isset($_POST['data'])) {
// take security precautions: filter all incoming data!
$email = (isset($_POST['data']['email'])) ? strip_tags($_POST['data']['email']) : '';
$password = (isset($_POST['data']['password'])) ? strip_tags($_POST['data']['password']) : '';
if ($email && $password) {
$result = $memberTable->loginByName($email, $password);
if ($result) {
// store user info in session
$_SESSION['membro'] = $result;
$_SESSION['login'] = TRUE;
}
else {
$_SESSION['login'] = FALSE;
}
// redirect back home
header('Location: ?page=paginaprincipal');
exit;
}
}
my html from login page is:
<div class="content">
<br/>
<div class="product-list">
<h2>Login</h2>
<br/>
<b>Por favor, entre a sua informacao.</b><br/><br/>
<form action="?page=login" method="POST">
<p>
<label>Email: </label>
<input type="text" name="data[email]" />
<p>
<p>
<label>Password: </label>
<input type="password" name="data[password]" />
<p>
<p>
<input type="reset" name="data[clear]" value="Clear" class="button"/>
<input type="submit" name="data[submit]" value="Submit" class="button marL10"/>
<p>
</form>
</div><!-- product-list -->
</div>
Please help me to identify what am I doing wrong. I've tried a lot of different things from here but none of them works and I need this work to be done as soon as possible that's why my frustation :-(