Foros del Web » Programando para Internet » PHP »

Ayuda: Warning: session_start()

Estas en el tema de Ayuda: Warning: session_start() en el foro de PHP en Foros del Web. Hola amigos, me decidi a hacer un sistema de registro deusuarios con dreamweaver, y lo subi a mi servidor para probarlo, y cuando me logeo ...
  #1 (permalink)  
Antiguo 14/07/2009, 09:41
 
Fecha de Ingreso: junio-2006
Mensajes: 83
Antigüedad: 17 años, 10 meses
Puntos: 0
Ayuda: Warning: session_start()

Hola amigos, me decidi a hacer un sistema de registro deusuarios con dreamweaver, y lo subi a mi servidor para probarlo, y cuando me logeo , y me desconecto todo bien.

Pero al momento de intnetar logearme por seguna ves pues cargo bien el menu de los usuarios, pero me aparecio este error:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home2/oviedosc/public_html/web/SU/mensuario.php:2) in /home2/oviedosc/public_html/web/SU/mensuario.php on line 4

Este es mi archivo:

Código PHP:

<?php
//initialize the session
session_start();

// ** Logout the current user. **
$logoutAction $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset(
$_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  
$logoutAction .="&"htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  
//to fully log out a visitor we need to clear the session varialbles
  
session_unregister('MM_Username');
  
session_unregister('MM_UserGroup');
    
  
$logoutGoTo "desconectado.php";
  if (
$logoutGoTo) {
    
header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
session_start
();
$MM_authorizedUsers "";
$MM_donotCheckaccess "true";

// *** 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 == "") && true) { 
      
$isValid true
    } 
  } 
  return 
$isValid
}

$MM_restrictGoTo "error_1.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;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=700,left = 262,top = 34');");
}
// End -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
.Estilo1 {
    font-family: "Monotype Corsiva";
    font-weight: bold;
    font-size: 24px;
}
.Estilo2 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 16px;
}
.Estilo3 {font-family: Verdana, Arial, Helvetica, sans-serif}
-->
</style>
</head>

<body>
<p align="center" class="Estilo1"><img src="post-it.jpg" width="64" height="64"><span class="Estilo2">Menu de Ex-Alumnos </span></p>
<table width="306" border="0" align="center">
  <tr>
    <td><a href="javascript:popUp('usuarios_galeria.php')" class="Estilo3">Ver Fotos de usuarios </a></td>
  </tr>
  <tr>
    <td width="300"><span class="Estilo3"><a href="javascript:popUp('usuarios_registrados.php')">Ver usuarios registrados</a></span></td>
  </tr>
  <tr>
    <td><a href="javascript:popUp('subir_imagen.php')" class="Estilo3">Enviar Fotos </a></td>
  </tr>
  <tr>
    <td><a href="<?php echo $logoutAction ?>" class="Estilo3">Desconectar</a></td>
  </tr>
  <tr>
    <td>
        </td>
  </tr>
</table>

</body>
</html>
  #2 (permalink)  
Antiguo 14/07/2009, 09:42
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Ayuda: Warning: session_start()

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

Saludos.
  #3 (permalink)  
Antiguo 14/07/2009, 09:43
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 11 meses
Puntos: 1517
Respuesta: Ayuda: Warning: session_start()

Primero quita el segundo session_start() y segundo quita el espacio que hay al principio del <?php Asegurate que no haya espacio alguno antes del <?php y tercero puede ser el formato en que grabaste el archivo.

Edito:
GatorV te dio la solucion para la tercera opcion que te dije
  #4 (permalink)  
Antiguo 14/07/2009, 09:49
 
Fecha de Ingreso: junio-2006
Mensajes: 83
Antigüedad: 17 años, 10 meses
Puntos: 0
Respuesta: Ayuda: Warning: session_start()

Ups me equivoque el primer session_start() aunque asi ya no aparece el error

Orale, no sabia que foros del web tenia wiki
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 16:55.