0

So i've finally uploaded my work from wamp to my actual website.

Everything seems to runs completely fine except header();

Example:

I have so if you're not logged in and try to access the logout url, it would redirect you to the login page.

if(!isset($_SESSION['loggedin'])){ header("Location: index.php?page=login"); exit();

on my localhost on wamp, it works perfect. Although on my website, it doesn't redirect.

I saw a post about this that recommended to use javascript redirect instead but i feel like it's unnecessary since there must be a way to sort this issue with using php.

RESOLVED: The host had the wrong version running and took 3 days to respond.

Aberidius
  • 21
  • 6
  • 99.99999% chance it's just a [headers already sent](http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php?rq=1) error. – Marc B Jul 22 '16 at 21:40
  • Nevermind, it's resolved. The host didn't wanna admit that they used a old version of the php. – Aberidius Jul 22 '16 at 21:55

1 Answers1

0

Use this replace for it

if(!isset($_SESSION['loggedin'])){
    echo "<script type='text/javascript'>window.location.href = 'index.php?page=login';</script>";
    exit();
}
Quynh Nguyen
  • 2,959
  • 2
  • 13
  • 27