1

I know guys you will hate me because this title is often founded here. But i searched after a solution and couldnt find one.
But please if you think this is a duplicate of the exact issue with description then please mark it as redirect with the URL of the duplicate.

Anyway lets come to my issue. Many people say that its because of a loop to itself which is often founded in the file itself.
Here is my index.php
On this file there isnt any redirects to itself but an include to auth.php.

<?php
session_start();
include("auth.php");
?>

In auth.php I got here the header and I thought this would be the "loop". But when I remove the header on this file index.php wont be executed, that means I got a white page displayed on the browser.

<?php
session_start();
if(!isset($_SESSION["username"])){
header("Location: ../index.php");
exit(); }
?>

How can I fix this correctly?

Kind regards :(

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
  • Check you're not on index.php before redirecting – KeepoN May 03 '18 at 20:31
  • @ChinLeung Yes I realised that thank you alot. To be honest I dont know how to continue. How should I change the code on auth.php without being redirected to much? Because I need this auth.php file –  May 03 '18 at 20:53
  • What is your `auth` supposed to do? – Chin Leung May 03 '18 at 20:57
  • It should authorize a user by his ame and redirect him to the index.php if its a valid session. –  May 03 '18 at 21:00
  • this is a typo question; you're starting the session twice. You need to remove one of them. You should be getting a warning about it already being started. – Funk Forty Niner May 03 '18 at 21:11

0 Answers0