Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<?php
session_start();
if(isset($_SESSION['uname']) || isset($_SESSION['pass']) ){
    if (isset($_REQUEST['logout']))
    {
        session_unset(); 
        session_destroy();
       echo "<script>location.href = 'login.php' </script> " ;
    } 
}
else
{
   echo "<script>location.href = 'login.php' </script> " ;
}
?>


What I have tried:

Tried Ob_Clean(), UTF-8 tried but have no luck
Posted
Updated 2-Jul-20 21:10pm
v2

1 solution

You can try the following -

PHP
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

if(isset($_SESSION['uname']) || isset($_SESSION['pass']) ){
    if (isset($_REQUEST['logout']))
    {
    session_destroy();
    } //else ...

//Change the echo part to -
header('Location: /login.php');
exit;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900