What i want to happen is for the page to redirect to login if you try to get to a page that you have got to by logging in.
Basically when i clear cookies and refresh staff.php i get this message:
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\widget_corp\includes\header.php:10) in C:\wamp\www\widget_corp\includes\functions.php on line 23
Here are the function and staff page code:
function.php:
***** PLEASE USE THE [CODE] TAG *****
Code: Select all
function redirect_to( $location = NULL ) {
if ($location != NULL) {
header("Location: {$location}");
exit;
}
}
Code: Select all
<?php require_once("includes/session.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php include("includes/header.php"); ?>
<?php
if (!isset($_SESSION['user_id'])){
redirect_to("login.php");
}
?>