Arqetech
Arqetech

Reputation: 483

PHP header('Location') redirect not working

I am working on a login script for my website and I can't use header('Location: url'); I'm using a live server for my tests Here's my code

<?php

ob_start();
session_start();

if (isset($_SESSION['username'])) {
    header('Location: http://some-website.com/user/');
    exit();
}

...

?>

But Instead of redirecting me to the URL given above It just shows the blank page Looks like It's using exit() but not header() I'm pretty confused

Upvotes: 0

Views: 423

Answers (1)

Ahmad
Ahmad

Reputation: 477

Well it looks like your condition is not verified that's why you're getting a blank page, try to check if $_SESSION global variable contains $_SESSION['username'] by adding before your if statement var_dump($_SESSION) then check out if 'username' is in it.

Upvotes: 1

Related Questions