Ajouter un commentaire

thesuixx
sessions

Bonjour,
j'ai un petit souci avec les sessions sur un site web
Les sessions passent trés bien sur un serveur ftp, mais buguent sous xampp et sur un ftp de free (j'ai pourtant crée le dossier 'sessions' à la racine).
Sous xampp et chez free, j'ai bien des fichiers de sessions crées ( respectivement dans C:\xampp\tmp et dans /sessions), mais ils sont vides

On me reproche:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /mnt/103/sdb/8/e/blacklagooncompany/LGS/index.php:1) in /mnt/103/sdb/8/e/blacklagooncompany/LGS/index.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /mnt/103/sdb/8/e/blacklagooncompany/LGS/index.php:1) in /mnt/103/sdb/8/e/blacklagooncompany/LGS/index.php on line 2

Pourtant la fonction session_start() est bien appelée avant toute écriture (echo ou print)

Un petit peu de code pour illustrer tout ça:

<?php

	//------------------------connexion à la base sql ------------------------
		/** le chemin vers le fichier contenant les variables $serveur, $user, $pass et $bd */
		$cheminFichierConnexion = "secure/sql.php";

		include $cheminFichierConnexion;
			
		// connexion
		$link = mysql_connect($serveur, $user, $pass) or die ("Impossible de se connecter à la BD");
		// selection db
		mysql_select_db($bd) or die ("Impossible de trouver la BD");
	// ------------------------fin connexion BD-----------------------------------
	
	// ------------------------la gestion des sessions-------------------------------
		include 'scripts/interfaceMembre.php';
	// -----------------------fin gestion sessions-----------------------------------
et le haut de la page interfaceMembre.php:
<?php
	// démarrage de la session: accés au fichier session (ou création)
	session_start();
	
	// appellé au moment du login
	if (isset($_POST['login']) && isset($_POST['pass'])){
		session_unset();    // destruction variables session 
		testLogin ($link, $_POST['login'], $_POST['pass']);
	}

voila, en principe il n'y a pas d'écriture avant la fonction session_start() mais c'est précisément de ça qu'on m'accuse (headers already sent bla bla bla...). Du coup, je me demande si je dois pas modifier quelque chose dans le php.ini(vu que les sessions marchent très bien sur un ftp, mais pas sous xampp ni free (malheureusement je n'ai pas accès au php.ini de ce ftp, sinon j'aurais déjà tout simplement copié le contenu de celui ci dans le php.ini de xampp):

[Session]
; Handler used to store/retrieve data.
session.save_handler = files

; Argument passed to save_handler.  In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
;
; As of PHP 4.0.1, you can define the path as:
;
;     session.save_path = "N;/path"
;
; where N is an integer.  Instead of storing all the session files in
; /path, what this will do is use subdirectories N-levels deep, and
; store the session data in those directories.  This is useful if you
; or your OS have problems with lots of files in one directory, and is
; a more efficient layout for servers that handle lots of sessions.
;
; NOTE 1: PHP will not create this directory structure automatically.
;         You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
;         use subdirectories for session storage
;
; The file storage module creates files using mode 600 by default.
; You can change that by using
;
;     session.save_path = "N;MODE;/path"
;
; where MODE is the octal representation of the mode. Note that this
; does not overwrite the process's umask.
session.save_path = "C:\xampp\tmp"

; Whether to use cookies.
session.use_cookies = 1

; This option enables administrators to make their users invulnerable to
; attacks which involve passing session ids in URLs; defaults to 0.
; session.use_only_cookies = 1

; Name of the session (used as cookie name).
session.name = PHPSESSID

; Initialize session on request startup.
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

; The path for which the cookie is valid.
session.cookie_path = /

; The domain for which the cookie is valid.
session.cookie_domain =

j'allais oublier le résultat:

<br />
<b>Warning</b>:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /mnt/103/sdb/8/e/blacklagooncompany/LGS/index.php:1) in <b>/mnt/103/sdb/8/e/blacklagooncompany/LGS/index.php</b> on line <b>2</b><br />
<br />
<b>Warning</b>:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /mnt/103/sdb/8/e/blacklagooncompany/LGS/index.php:1) in <b>/mnt/103/sdb/8/e/blacklagooncompany/LGS/index.php</b> on line <b>2</b><br />

<!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">
<head>
...

Filtered HTML

Plain text

CAPTCHA
Cette question permet de vérifier que vous n'êtes pas un robot spammeur :-)
 K  K   CCC  FFFF   GGG   L    
K K C F G L
KK C FFF G GG L
K K C F G G L
K K CCC F GGG LLLL