PHP Signin Signout Application

//html code

hello



//php code
<?php
session_start();
$sid=session_id();
if((isset($_SESSION["sid"]))and (isset($_COOKIE["sid"]))){
   echo  "Welcome".$_COOKIE["sid"]."<a href='signout.php'>Signout</a>"."<br/>";
}else{
if(isset($_POST['email'])and isset($_POST['pwd'])){
    if(($_POST['email']=="aashishmittal.id@gmail.com")and ($_POST['pwd']=="1234")){
  
   setcookie("sid",$sid);
   $_SESSION['sid']=$sid;
   //setcookie("pwd","1234");
  
   echo  "Welcome".$_COOKIE["sid"]."<a href='signout.php'>Signout</a>"."<br/>";

   
    }else{
        echo"Invalid Emailid or Password <br/>";
   
    }
}else{

header('location:http://localhost/php/test.html');

}
}

?>



//signout.php
session_start();
unset($_SESSION['sid']);
unset($_COOKIE['sid']);
session_destroy();
//echo $_SESSION['sid'];

header('location:http://localhost/php/test.html');




Reactions: