php - How to fix session not starting after unsetting a variable -
please have been trying fix not working out right me. have session started after logging out using unset($_session['variable']
, unable login session not setting.
please me out. note: unable login after unsetting variable. //this login.php
<?php session_start(); ob_start(); $msg = ""; if (isset($_post['login'])){ include "dbconnect.php"; if($_session['emaill'] !== null){ $emaill= $_session['emaill']; $password = $_post['password']; if (empty($emaill && $password) == false){ $sql = "select * `sono` `email`='$emaill' && `password`='$password'"; $check = mysqli_query($dbconnect, $sql) or die (mysqli_error($dbconnect)); $result = mysqli_num_rows($check); if ($result > 0){ $emaill= $_session['emaill']; header ('location: home.php'); exit(); } else $msg = "<p style='color: red; padding-left: 10px'>invalid password or email address</p>"; } else $msg = "<p style='color: red; padding-left: 10px'>please enter email , password login</p>"; } else $msg = "<p style='color: red; padding-left: 10px'>my scripts not working yet</p>"; } ?> // logout <?php session_start(); if (isset($_session['emaill'])){ unset($_session['emaill']); header('location: login.php'); } ?>
before using $_session['emaill'], check isset() :
if( isset($_session['emaill']) && $_session['emaill'] !== null){ ---- --- }
Comments
Post a Comment