Cannot send session cache limter
Mike_Watt Aug 12, 2009 12:10 AMI know that these "cannot send header" problems are everywhere - and I've read through at least twenty of them here before posting this.
I'm getting the error:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/d/j/m/djmikewatt/html/sites/imaging101/video.php:2) in /home/content/d/j/m/djmikewatt/html/sites/imaging101/video.php on line 4
at the top of a page. This error only shows up when the "restrict access to page" behavior is inerted. Remove it, and the page doesn't return the error anymore. This is one page out of many on my site that use this behavior - yet the only one returning this error. Below is all the code above the <html> tag - can anyone spot the problem?
Help is appreciated.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php require_once('Connections/imaging101.php'); ?>
<?php if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "4,1";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "access_denied.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$uid = $row_rs_user['id'];
$colname_rs_user = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_rs_user = $_SESSION['MM_Username'];
}
mysql_select_db($database_imaging101, $imaging101);
$query_rs_user = sprintf("SELECT id FROM users WHERE username = %s", GetSQLValueString($colname_rs_user, "text"));
$rs_user = mysql_query($query_rs_user, $imaging101) or die(mysql_error());
$row_rs_user = mysql_fetch_assoc($rs_user);
$totalRows_rs_user = mysql_num_rows($rs_user);
mysql_select_db($database_imaging101, $imaging101);
$query_rs_files = "SELECT record_id, video_1, video_2 FROM downloads";
$rs_files = mysql_query($query_rs_files, $imaging101) or die(mysql_error());
$row_rs_files = mysql_fetch_assoc($rs_files);
$totalRows_rs_files = mysql_num_rows($rs_files);
?>



