Précédent   Forum des professionnels en informatique > PHP > Langage > Sessions
Sessions Forum d'entraide sur les sessions avec PHP. Avant de poster -> FAQ sessions, Cours sessions et Sources sécurité
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 11/12/2007, 10h47   #1
Membre du Club
 
Avatar de zabdaniel
 
Inscription : février 2007
Messages : 175
Détails du profil
Informations personnelles :
Âge : 26
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : février 2007
Messages : 175
Points : 54
Points : 54
Par défaut échec du démarrage de session

Bonjour j'ai un problème de démarrage de session
voici mon code :
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
 
<?php
 
session_start();
include_once("fonctions-panier.php");
if (isset($_GET['action']))
{
$erreur=false;
 if(in_array( $_GET['action'],array('ajout', 'suppression', 'refresh')))
  $action = $_GET['action'];
 else
  $erreur=true;
 
 $l = preg_replace('#\v#', '', $_GET['l']);
 
 $q = intval($_GET['q']);
 
}
 
elseif(isset($_POST['action']))
{
 unset($_GET);
 $erreur=false;
 
 if(in_array($_POST['action'],array('ajout', 'suppression', 'refresh')))
  $action=$_POST['action'];
 else
  $erreur=true;
 
  $l = preg_replace('#\v#', '',$_POST['l']);
 
 
 $QteArticle = array();
 
 $i=0;
 foreach ($_POST['QteArticle'] as $contenu){
  $QteArticle[$i++] = intval($contenu);
 
 }
 
}
 
 
 
 
if ($erreur==false){
 
 switch($action){
 
  Case "ajout":
  ajouterArticle($l,$q);
  break;
 
  Case "suppression":
  supprimerArticle($l);
  break;
 
  Case "refresh" :
 
  for ($i = 0 ; $i < count($QteArticle) ; $i++)
  {
    modifierQTeArticle($_SESSION['panier']['libelleProduit'][$i],round($QteArticle[$i]));
  }
  break;
 
  Default:
  break;
 
 }
}
 
echo '<?xml version="1.0" encoding="iso-8859-1"?>';?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"> 
<head>
<title>Votre panier</title>
</head>
<body>
 
<form method="post" action="file:///C|/Documents and Settings/user.SHAMOR/Bureau/panier.php">
<table style="width: 400px">
<tr>
      <td colspan="4">Votre panier</td >
</tr>
<tr>
      <td>Libellé</td>
      <td>Quantité</td>
      <td>Action</td>
</tr>
 
 
<?php
if (creationPanier())
{
$nbArticles=count($_SESSION['panier']['libelleProduit']);
  if ($nbArticles <= 0)
   echo "<tr><td>Votre panier est vide </ td></tr>";
  else
  {
   for ($i=0 ;$i < $nbArticles ; $i++)
   {
    echo "<tr>";
    echo "<td>".htmlspecialchars($_SESSION['panier']['libelleProduit'][$i])."</ td>";
    echo "<td><input type=\"text\" size=\"4\" name=\"QteArticle[]\" value=\"".htmlspecialchars($_SESSION['panier']['qteProduit'][$i])."\"/></td>";
    echo "<td><a href=\"".htmlspecialchars("panier.php?action=suppression&l=".rawurlencode($_SESSION['panier']['libelleProduit'][$i]))."\">XX</a></td>";
    echo "</tr>";
   }
 
  echo "<tr><td colspan=\"2\"> </td>";
  echo "<td colspan=\"2\">";
  echo "</td></tr>";
 
  echo "<tr><td colspan=\"4\">";
  echo "<input type=\"submit\" value=\"Rafraichir\"/>";
  echo "<input type=\"hidden\" name=\"action\" value=\"refresh\"/>";
 
  echo "</td></tr>";
  }
}
?>
</table>
</form>
</body>
</html>

et voici le message d'erreur qui est affiché : Warning: session_start(): Cannot send session cookie - headers already sent by (output started at d:\program files\easyphp1-8\www\panier seul\panier.php:2) in d:\program files\easyphp1-8\www\panier seul\panier.php on line 4

zabdaniel est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/12/2007, 10h53   #2
Membre Expert
 
Inscription : octobre 2002
Messages : 1 141
Détails du profil
Informations personnelles :
Âge : 32
Localisation : France, Rhône (Rhône Alpes)

Informations forums :
Inscription : octobre 2002
Messages : 1 141
Points : 1 204
Points : 1 204
Envoyer un message via MSN à Raideman
Vérifie bien que tu n'envoies rien, même pas un espace au navigateur avec le session_start();
essaie par exemple:
Code :
1
2
<?php
session_start();
Raideman est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/12/2007, 11h08   #3
Membre du Club
 
Avatar de zabdaniel
 
Inscription : février 2007
Messages : 175
Détails du profil
Informations personnelles :
Âge : 26
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : février 2007
Messages : 175
Points : 54
Points : 54
ouah je savais pas que mettre une ligne d'espace ça pouvais bloquer en tout cas je le saurais pour la prochaine fois merci beaucoup
zabdaniel est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 13h06.


 
 
 
 
Partenaires

Hébergement Web