I am trying to create a snippet of PHP that checks if the user has signed up using Sessions when they reach my index page, and if they haven't, I will redirect them to the signup page.
I have started the Session after the user has signed up, but I can't seem to check on my index page to check if the session has started or not.
Sign up PHP:
    session_start();
    //create connection
    //check for errors in the form
    if(!$error) {
        //insert values from form to sql database
        $_SESSION['login_user'] = $username;
        //email user
    }
?>
index.php
<?PHP
    include("signupphp.php");
    if(!$username) {
        echo '<script>location.href = "https://google.com";</script>';
    }
 ?>
Ideally, I would want when the user signs up, it creates the session, and whenever they go to the index.php, it checks to see whether they have signed up, and if they haven't, it will redirect them to the signup page.
 
     
     
    