Home > Software design >  PHP $_SESSION preventing or blocking website load
PHP $_SESSION preventing or blocking website load

Time:04-06

I have a simple page to check if the session are set or no

session_start();
if (!isset($_SESSION['id'])) {
    $_SESSION['checkin'] = 'yes';
    header("Location: https://blabla.php");
    exit();
} else {
    // do something here
}


<HTM>
web page
</HTML>

everytime i the session is not set, i would not load the page. i have try to delete the exit() funciton, page load correctly, but i cannot redirect it to the url

EDIT :

I am forget to write session_start(); here, but in my real code, they already inputed

CodePudding user response:

It is likely that you have a non-header output before the header line. Try adding an ob_start() after the session_start().

  • Related