Foros del Web » Programando para Internet » PHP »

Warning: session_start() [function.session-start]: Cannot send session cache limiter

Estas en el tema de Warning: session_start() [function.session-start]: Cannot send session cache limiter en el foro de PHP en Foros del Web. Buenas Tardes a tod@s, Soy nuevo en el foro y me gustaría pedir algo de ayuda, he estado leyendo todo acerca de este error y ...
  #1 (permalink)  
Antiguo 24/09/2012, 09:56
Avatar de demevoley  
Fecha de Ingreso: septiembre-2012
Ubicación: Madrid
Mensajes: 6
Antigüedad: 11 años, 7 meses
Puntos: 0
Warning: session_start() [function.session-start]: Cannot send session cache limiter

Buenas Tardes a tod@s,

Soy nuevo en el foro y me gustaría pedir algo de ayuda, he estado leyendo todo acerca de este error y no consigo solucionar el problema.

No tengo espacios delante ni detras de <?php ?>
Lo tengo con codificación ANSI
No se de que puede ser el problema, les paso mi código:

Este corresponde al archivo acceso.php


<?php require_once('Connections/conexiontiendate.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
?><?php
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['strEmail'])) {
$loginUsername=$_POST['strEmail'];
$password=$_POST['strPassword'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "acceso_ok.php";
$MM_redirectLoginFailed = "acceso_error.php";
$MM_redirecttoReferrer = false;
$cadena= "ada32445#~@as5";
$pass=$_POST['strPassword'];
$hash=$cadena.sha1($pass);
$usu= split(" ",trim($_POST["strUsuario"]));
mysql_select_db($database_conexiontiendate, $conexiontiendate);

$LoginRS__query=sprintf("SELECT idUsuario, strEmail, strPassword FROM tblusuario WHERE strEmail=%s AND strPassword=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($hash, "text"));

$LoginRS = mysql_query($LoginRS__query, $conexiontiendate) or die(mysql_error());
$row_LoginRS = mysql_fetch_assoc($LoginRS);
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
$_SESSION['MM_IdUsuario'] = $row_LoginRS["idUsuario"];

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Principal.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>.: XEREZADE :. Coffee And Tea Shop</title>


<div class="sidebar1">
<!-- InstanceBeginEditable name="EditRegion7" --><?php include("includes/sidebar1.php"); ?><!-- InstanceEndEditable -->

</div>



Esto es conexiontiendate.php

<?php if(!isset($_SESSION)){session_start();}?><?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conexiontiendate = "XXXXXX";
$database_conexiontiendate = "XXXXXX";
$username_conexiontiendate = "XXXXXX";
$password_conexiontiendate = "XXXXXXXX";
$conexiontiendate = mysql_pconnect($hostname_conexiontiendate, $username_conexiontiendate, $password_conexiontiendate) or trigger_error(mysql_error(),E_USER_ERROR);
?>
<?php
if (is_file("includes/funciones.php")){
include ("includes/funciones.php");
}
else
{
include ("../includes/funciones.php");}
?>

Este corresponde a acceso_ok.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Principal.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>.: XEREZADE :. Coffee And Tea Shop</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="css/principal.css" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Dosis:400,300,700' rel='stylesheet' type='text/css'>


<div class="sidebar1">
<!-- InstanceBeginEditable name="EditRegion7" --><?php include("includes/sidebar1.php"); ?><!-- InstanceEndEditable -->


</div>
<div class="content">
<!-- InstanceBeginEditable name="WELCOME" --><!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="flash" --><!-- InstanceEndEditable -->

<h1 class="h1"><!-- InstanceBeginEditable name="titulo" --><p class="titulote">Hola <?php include("includes/accesor.php");?></p><!-- InstanceEndEditable --></h1>
<!-- InstanceBeginEditable name="comentario" -->
<blockquote>
<p>Muchas Gracias por acceder a Xerezade</p>
</blockquote>
<!-- InstanceEndEditable --><!-- end .content --></div>
<div class="footer">

</html>

Les dejo también los includes para ver si puede ser de ahi

accesor:

<?php require_once('Connections/conexiontiendate.php'); ?>
<?php
if ((isset($_SESSION['MM_Username'])) && ($_SESSION['MM_Username'] != ""))
{
echo " ";
echo ObtenerNombreUsuario($_SESSION['MM_IdUsuario']);
}?>



Gracias anticipadas y espero que me puedan ayudar
Reciban un saludo
Deme
  #2 (permalink)  
Antiguo 24/09/2012, 10:01
Avatar de demevoley  
Fecha de Ingreso: septiembre-2012
Ubicación: Madrid
Mensajes: 6
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: Warning: session_start() [function.session-start]: Cannot send session cac

Por cierto el error completo es este

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\inetpub\vhosts\xerezade.es\httpdocs\acceso_ok.p hp:6) in C:\inetpub\vhosts\xerezade.es\httpdocs\Connections \conexiontiendate.php on line 1
  #3 (permalink)  
Antiguo 24/09/2012, 10:16
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Warning: session_start() [function.session-start]: Cannot send session cac

Lee lo siguiente:

http://www.forosdelweb.com/wiki/PHP:...n_line_4%22%3F

http://www.forosdelweb.com/wiki/PHP:...lready_sent%3F
  #4 (permalink)  
Antiguo 24/09/2012, 10:36
Avatar de demevoley  
Fecha de Ingreso: septiembre-2012
Ubicación: Madrid
Mensajes: 6
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: Warning: session_start() [function.session-start]: Cannot send session cac

Gracias por tu respuesta GatorV

Ya había leído estos 2 documentos y muchos más antes de lanzarme a publicar mi problema.

Pero como he dicho antes, no tengo ningún espacio en blanco ni ninguna sentencia que envíe cabeceras antes del código php.

Por otro lado tampoco tengo los archivos en UTF-8 sino que los tengo en codificación ANSI

Un saludo
Deme
  #5 (permalink)  
Antiguo 24/09/2012, 12:11
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Warning: session_start() [function.session-start]: Cannot send session cac

Pues el error es claro y PHP no lo inventa, revisa que tienes en acceso_ok.php en la línea 6, ya que ahí es donde ocurre la salida de texto.

Saludos.
  #6 (permalink)  
Antiguo 24/09/2012, 16:08
Avatar de demevoley  
Fecha de Ingreso: septiembre-2012
Ubicación: Madrid
Mensajes: 6
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: Warning: session_start() [function.session-start]: Cannot send session cac

En la linea 6 de acceso_ok.php esta el título de la página

<title>.: XEREZADE :. Coffee And Tea Shop</title>

De nuevo gracias

pero el error no es ese!!!
  #7 (permalink)  
Antiguo 24/09/2012, 16:42
 
Fecha de Ingreso: septiembre-2012
Ubicación: Bien lejos
Mensajes: 9
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: Warning: session_start() [function.session-start]: Cannot send session cac

Cita:
Iniciado por demevoley Ver Mensaje
Por cierto el error completo es este

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\inetpub\vhosts\xerezade.es\httpdocs\acceso_ok.p hp:6) in C:\inetpub\vhosts\xerezade.es\httpdocs\Connections \conexiontiendate.php on line 1
Mira amigo, ese no es un error , es un warning y se debe a que usar session_start()

en versiones de php actuales aparece este warning, antes ni siquiera tenias que poner isset para saber si ya hay una versión iniciada
isset() sólo trabaja con variables, ya que pasar cualquier otra cosa dará como resultado un error de intérprete.

te recomiendo poner algo como
if(!isset($_SESSION['PrevUrl']))

o alguna variable pero no $_SESSION

por que posiblemente esta entrando a ese if y se lanza esa funcion y te marca ese warning
  #8 (permalink)  
Antiguo 24/09/2012, 17:25
Avatar de oso96_2000  
Fecha de Ingreso: junio-2002
Ubicación: Distrito Federal
Mensajes: 558
Antigüedad: 21 años, 10 meses
Puntos: 35
Respuesta: Warning: session_start() [function.session-start]: Cannot send session cac

Cita:
Iniciado por demevoley Ver Mensaje
En la linea 6 de acceso_ok.php esta el título de la página

<title>.: XEREZADE :. Coffee And Tea Shop</title>

De nuevo gracias

pero el error no es ese!!!
El error ES ese. Deberias leer bien los temas que te puso GatorV, este tema se ha respondido infinidad de veces... (Aproximadamente 84,800,000 resultados con "Cannot send session cache limiter - headers already sent" de búsqueda en google).

En concreto, del primer enlace, es esto: "No se puede nunca enviar texto antes de enviar cabeceras HTTP (con header(), set_cookie() o session_start(). )"
__________________
Sin Ideas
  #9 (permalink)  
Antiguo 24/09/2012, 20:52
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Warning: session_start() [function.session-start]: Cannot send session cac

<title>.: XEREZADE :. Coffee And Tea Shop</title> es texto, en particular HTML, al decir que no puedes enviar texto significa cualquier cosa que no sea PHP, esta incluye HTML, CSS, Javascript, etc, no puedes hacer nada de esto antes de llamar a session_start().
  #10 (permalink)  
Antiguo 25/09/2012, 15:37
 
Fecha de Ingreso: septiembre-2012
Ubicación: Bien lejos
Mensajes: 9
Antigüedad: 11 años, 7 meses
Puntos: 0
De acuerdo Respuesta: Warning: session_start() [function.session-start]: Cannot send session cac

el error esta en conextiontiendate.php
como lo dije anteriormente

Mira amigo, ese no es un error , es un warning y se debe a que usar session_start()

en versiones de php actuales aparece este warning, antes ni siquiera tenias que poner isset para saber si ya hay una versión iniciada
isset() sólo trabaja con variables, ya que pasar cualquier otra cosa dará como resultado un error de intérprete.

te recomiendo poner algo como
if(!isset($_SESSION['PrevUrl']))

o alguna variable pero no $_SESSION

por que posiblemente esta entrando a ese if y se lanza esa funcion y te marca ese warning



me hice los archivos y me salia ese warning y se corrigio como te dije
  #11 (permalink)  
Antiguo 26/09/2012, 06:26
Avatar de demevoley  
Fecha de Ingreso: septiembre-2012
Ubicación: Madrid
Mensajes: 6
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: Warning: session_start() [function.session-start]: Cannot send session cac

Buenas a tod@s,

Gracias por vuestra ayuda, finalmente el error estaba en que en la página a la que acudía cuando el usuario estaba logueado, no tenía la línea de código llamando a la conexión de la BD.

Por lo tanto, al ser php estabais en lo cierto, el html prevalecía y por eso salía el warning, gracias por vuestra ayuda y por vuestra paciencia

Recibir un saludo
Deme

Etiquetas: cache, html, mysql, send, session, sql, warning, variables, usuarios
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:52.