Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/05/2009, 18:38
th3r0rn
 
Fecha de Ingreso: noviembre-2007
Mensajes: 504
Antigüedad: 16 años, 5 meses
Puntos: 2
Problema con sesiones

Hola, tengo un problema con las sesiones que no se por que este pasando, el codigo de la web protegida es:
Código PHP:
    <?php
   
include("../includes/config.php");    
    
session_start();

 

    
?>

    <?
    
if (isset($_SESSION['s_username'])) {
    echo 
"Bienvenido a mi sitio has ingresado como ".$_SESSION['s_username'].", gracias por la visita!";
    }else{
    echo 
"Tu no estas autentificado dirígete a login.php o registrate en register.php";
    echo 
$_SESSION['s_username'];
    }
    
?>
y el error que me da es:
Código:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/phpmexic/public_html/pruebas/users/web.php:1) in /home/phpmexic/public_html/pruebas/users/web.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/phpmexic/public_html/pruebas/users/web.php:1) in /home/phpmexic/public_html/pruebas/users/web.php on line 3
Tu no estas autentificado dirÃ*gete a login.php o registrate en register.php
incluso eso de q no estoy autentificado no se por q lo da, si si inicio sesion en mi pagina de login:
Código PHP:
    <?PHP
   
include("../includes/config.php");
    
session_start();

    if (
$_POST['username']) {
    
//Comprobacion del envio del nombre de usuario y password
    
$username=$_POST['username'];
    
$password=$_POST['password'];
    if (
$password==NULL) {
    echo 
"La password no fue enviada";
    }else{
    
$query mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
    
$data mysql_fetch_array($query);
    if(
$data['password'] != $password) {
    echo 
"Login incorrecto";
    }else{
    
$query mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
    
$row mysql_fetch_array($query);
    
$_SESSION["s_username"] = $row['username'];
    echo 
"Has sido logueado correctamente ".$_SESSION['s_username']." y puedes acceder al index.php.";
    }
    }
    }
    
?>
la cual cuando inicio sesion me da este error:
Código:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/phpmexic/public_html/pruebas/users/web.php:1) in /home/phpmexic/public_html/pruebas/users/web.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/phpmexic/public_html/pruebas/users/web.php:1) in /home/phpmexic/public_html/pruebas/users/web.php on line 3
Tu no estas autentificado dirÃ*gete a login.php o registrate en register.php
no se por que :(
podrian ayudarme? Gracias