Foros del Web » Programando para Internet » PHP »

Error: Warning: session_start() [function.session-start]: Cannot send session cookie

Estas en el tema de Error: Warning: session_start() [function.session-start]: Cannot send session cookie en el foro de PHP en Foros del Web. Código PHP: Warning :  session_start () [function. session - start ]:  Cannot send session cookie  -  headers already sent by  ( output started at  / home / nomojueg / public_html / includes / core ...
  #1 (permalink)  
Antiguo 13/11/2011, 10:40
 
Fecha de Ingreso: julio-2011
Mensajes: 5
Antigüedad: 12 años, 9 meses
Puntos: 0
Error: Warning: session_start() [function.session-start]: Cannot send session cookie

Código PHP:
Warningsession_start() [function.session-start]: Cannot send session cookie headers already sent by (output started at /home/nomojueg/public_html/includes/core.php:1in /home/nomojueg/public_html/login.php on line 5

Warning
session_start() [function.session-start]: Cannot send session cache limiter headers already sent (output started at /home/nomojueg/public_html/includes/core.php:1in /home/nomojueg/public_html/login.php on line 5 
¿Porqué hay este error? El código PHP es el siguiente:

Código PHP:
<?php
if (isset($_GET["done"])) {
    require_once 
'config.php';
    include 
'includes/core.php';
    
session_start();
    if ((!
$_POST['username']) || (!$_POST['password'])) { // User did not type a username and password        
        
header("Location: index.php?task=login&em=1");
    }
    else {
        
$username mysql_secure($_POST['username']);
        
$password md5($_POST['password']);

        
$sql mysql_query("SELECT * FROM ava_users WHERE username='$username' AND password='$password' AND activate='1'");
        
$login_check mysql_num_rows($sql);

        if (
$login_check 0) {
            
$row mysql_fetch_array($sql);
            
$user_id $row['id'];
            
            if (isset(
$_POST['remember'])) {
                
setcookie("ava_username"$usernametime()+60*60*24*100);
                
setcookie("ava_code"$passwordtime()+60*60*24*100);
                
setcookie("ava_userid"$user_idtime()+60*60*24*100);
            }
            else {
                
setcookie("ava_username"$username);
                
setcookie("ava_code"$password);
                
setcookie("ava_userid"$user_id); 
            }

            if (isset(
$_GET['action']) && $_GET['action'] == 'admin') {
                
header("Location: admin/index.php");
            }
            else if (isset(
$_GET['nexttask'])) {
                if (
$_GET['nexttask'] == 'login') {
                    
header("Location: index.php");
                }
                else {
                    
header("Location: index.php?task=".$_GET['nexttask']."&amp;id=".$_GET['nextid']."");
                }
            }
            else {
                
header("Location: index.php");
            }
        } 
        else {
            
header("Location: index.php?task=login&em=2");
        }
    }
}
else if (isset(
$_GET['action']) && $_GET['action'] == 'logout') {
    
setcookie("ava_username"""time()-60*60*24*100);
    
setcookie("ava_userid"""time()-60*60*24*100);
    
setcookie("ava_code"""time()-60*60*24*100);
    
setcookie("ava_iptrack"""time()-60*60*24*100);
    
header("Location: index.php");
}
else { 
// No info was submitted - user is requesting login form
    
if (isset($_GET['em'])) {
        if (
$_GET['em'] == 1) {
            
$error_message LOGIN_ERROR1;
        }
        else {
            
$error_message LOGIN_ERROR2;
        }
    }
    if (isset(
$template['login_form'])) {
        include 
'.'.$setting['template_url'].'/'.$template['login_form'];
    }
    else {
        include 
'includes/forms/login_form.php';
    }
}
?>
  #2 (permalink)  
Antiguo 13/11/2011, 11:38
 
Fecha de Ingreso: septiembre-2007
Ubicación: PyRoot
Mensajes: 1.515
Antigüedad: 16 años, 7 meses
Puntos: 188
Respuesta: Error: Warning: session_start() [function.session-start]: Cannot send sess

antes de session_start() no debe haber ninguna salida HTML, o algun print, echo, un espacio en blanco fuera de las etiquetas <?php o ?>
__________________
Si quieres agradecer el triangulo obscuro de la parte derecha debes presionar +.
  #3 (permalink)  
Antiguo 13/11/2011, 11:44
Avatar de charlyalegret  
Fecha de Ingreso: septiembre-2011
Ubicación: Barcelona
Mensajes: 705
Antigüedad: 12 años, 7 meses
Puntos: 140
Respuesta: Error: Warning: session_start() [function.session-start]: Cannot send sess

Revisa que en los archivos que incluyes al principio, no se haya enviado html con ningún echo, print, etc.... para enviar cabeceras, sesiones, galletas, no puedes haber enviado nada de html

Puedes revisar:


- http://www.forosdelweb.com/wiki/PHP:...lready_sent%3F

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

http://www.forosdelweb.com/f18/error...mation-916736/

Suerte

Etiquetas: cookie, html, mysql, send, session, sql, warning
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 22:00.