[Cookies] Warning: session_start() Cannot send session cookie ...
Bonjour à tous,
Je suis en train de créer un petit site web avec ma formation informatique.J'ai un problème avec la session dans ma partie login.
Message d'erreur :
Citation:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\wamp\www\Galery\login.php:1) in C:\wamp\www\Galery\login.php on line 17
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\Galery\login.php:1) in C:\wamp\www\Galery\login.php on line 17
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\Galery\login.php:1) in C:\wamp\www\Galery\login.php on line 19
Comme je suis un bon élève je suis aller voir dans la partie FAQ session :
la commande session_start() doit impérativement être exécutée avant tout envoi par le serveur d'en-têtes HTTP au navigateur.
Dans mon cas je vais une série de test avant de lancer la session, je vous mets le code correspond à l'erreur :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| <?php
if(isset($_POST['connexion']) && $_POST['connexion'] == 'Connexion')
{
if ((isset($_POST['login']) && !empty($_POST['login'])) && (isset($_POST['password']) && !empty($_POST['password'])))
{
$login =$_POST['login'];
$password = $_POST['password'];
$connexion = mysql_connect("localhost","root","");
mysql_select_db('gallery',$connexion) or die("erreur base");
$select = "SELECT * from user WHERE login='$login' AND mdp='$password'";
$requete = mysql_query($select) or die ("Erreur select"."<br/>".$select);
if(mysql_num_rows($requete)==1)
{
session_start() or die("Impossible de lancer la session");
$_SESSION['login'] = $_POST['login'];
header('Location: membre.php');
}
else
{
$erreur = "Connexion impossible!";
}
}
else
{
$champs = " Les champs ne sont pas remplies ";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html>
<head>
<title> Webgallery </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="Content-Style-Type" content="text/css" />
</head>
<body>
<form action="login.php" method="post">
<table>
<tr>
<td>Login : </td>
<td> <input type="text" name="login" size="15" /></td>
</tr>
<tr>
<td>Mot de passe : </td>
<td> <input type="password" name="password" size="15" /></td>
</tr>
<tr>
<td>   </td>
<td> <input type="submit" name="connexion" value="Connexion" /></td>
</tr>
</table>
</form>
<?php
if (isset($erreur)) echo $erreur;
if (isset($champs)) echo $champs;
?>
<br/>
<br/>
<a href="inscription.php"> Inscription </a>
</body>
</html> |
Voila si quelqu'un peut jeter un coup d'œil et m'aider ça serait super.
Merci d'avance