1 replies
I have this little script I'm trying to simply logout here it is..

PHP Code:
<?php
session_start
();
  include(
"connect.php");
$username1 $_SESSION['username'];

if (!isset(
$_SESSION['$username'])) {
     echo 
"Sorry Your Not Logged In" $_session['username'];
    exit(); 
    
}
else if (isset(
$_GET['logout'])) {
session_destroy();
echo 
"You Have Been Successfully Logged Out";

    
}
  
?>
ok so what I'm saying is if the session isn't set would mean they are not logged in to logout right? then echo the sorry.. and exit.

else if the logout button was pressed destroy the session and echo success pretty straight forward

now if I change that and echo out that $username1 = $_SESSION['username'] echos fine so that tells me that the session is set ??? dosn't it?

issue is i'm always getting the sorry your not logged in but not the username??

what am I doing wrong here?
#session
  • Profile picture of the author phpg
    You have mistyped a variable here:

    if (!isset($_SESSION['$username'])) {

    should be $_SESSION['username'] , not $_SESSION['$username']
    {{ DiscussionBoard.errors[6050595].message }}

Trending Topics