Visualizzazione dei risultati da 1 a 2 su 2

Discussione: problema SESSION

  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2012
    Messaggi
    37

    problema SESSION

    Salve a tutti, sto provando ad usare delle session per gestire dei login sul mio sito il problema mi sorge quando vado ad effettuare il login e mi da 4 righe di errore :

    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Users\Utente\Desktop\sitophp\sitozio\login2.php :361) in C:\Users\Utente\Desktop\sitophp\sitozio\login2.php on line 376

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Users\Utente\Desktop\sitophp\sitozio\login2.php :361) in C:\Users\Utente\Desktop\sitophp\sitozio\login2.php on line 376


    Warning: Cannot modify header information - headers already sent by (output started at C:\Users\Utente\Desktop\sitophp\sitozio\login2.php :361) in C:\Users\Utente\Desktop\sitophp\sitozio\login2.php on line 388


    Vi posto solo il codice php presente nella mia pagina login2.php , in quanto ne ho fatte 2 di pagine: una con solo il codice html e relativo form , mentre un altra con l'apertura della sessione.

    <?php
    $con = mysql_connect("localhost","root","ascent");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("utenti", $con);
    $sql="SELECT username, password FROM utenti where username='$_POST[username]' and password='$_POST[password]'
    union
    select username, password from aziende where username='$_POST[username]' and password='$_POST[password]'";
    $risultato=mysql_query($sql);
    $prova=mysql_num_rows($risultato);
    if($prova==1){
    while($row = mysql_fetch_array($risultato)) {

    session_start();

    $idutente = $row['ID'];

    $nomeutente = $row['username'];

    $_SESSION['id_utente'] = $idutente;

    $_SESSION['nome_utente'] = $nomeutente;

    // e infine reindirizzo l'utente nella pagina protetta da login

    header("location: lavori.php");

    echo "Login effettuato con successo";
    }
    }
    else {
    echo "Dati incorretti";
    }
    mysql_close($con);
    ?>


    Premetto che senza la session funziona ( o abbastanza in quanto l'ultimo warning me lo da anche se non è presente , documentandomi ho visto che potrebbe essere un problema relativo all'header)

  2. #2
    Utente di HTML.it L'avatar di neroux
    Registrato dal
    Aug 2009
    Messaggi
    1,973

    Re: problema SESSION

    Originariamente inviato da addosso
    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Users\Utente\Desktop\sitophp\sitozio\login2.php :361) in C:\Users\Utente\Desktop\sitophp\sitozio\login2.php on line 376
    oppure zio Google

    www.sitemeer.com » Quando un sito pare irraggiungibile

    Se ti piace ci puoi trovare anche su Facebook

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.