Hey guys. I have made a simple session checking class that check if the session excists, if not then it redirects the user.
When I use this class I get "Warning: session_start(): Cannot send session cache limiter - headers already sent (output started...) in ... on line 11...
I think this has something with some white space or something in the file, but I have tried moving the code all the way to the first line with no spaces and this still happens... Any ideas?
Here is my code.
Thanks!
Session Class
<?php
class Session{
function checkSession($sessionName, $errorRedirect){
session_start();
if (!isset($_SESSION[$sessionName])){
// if session check fails, redirect user
header("Location: ".$errorRedirect);
}else{
header("Cache-Control: no-cache, must re-validate");
header("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
}//end if
}//end function checkSession
}//end class Session
?>
Use of it
<?php
require_once("includes/check_session.class.php");
$s = new Session();
$s->checkSession("USER_NAME","login.php");
?>