Warning sulle sessioni, come fare?

siriuxs

Nuovo Utente
17 Gen 2012
7
0
0
Ciao a tutti, ho un piccolo problema che mi sta letteralmente togliendo la salute... Ho quasi finito di sviluppare un piccolo CRM per la mia azienda, fatto da zero, scrivendo direttamente il codice e facendo tutto in Dreamweaver CS 5.

Il problema me lo da solo quando lo carico sul server register, mentre quando sono in locale va tutto liscio...

CRM realizzato in PHP.

Il problema è il seguente...

"Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /htdocs/public/www/crm/index.php:2) in /htdocs/public/www/crm/include/sessione.php on line 2"

Ma è una cavolata, infatti vi posto in breve parte del codice.

index.php:

PHP:
<head>
  	<?php
		include("include/sessione.php");
		include("include/foglicss.html");
	?>
    <title>Pagina di supporto ADV-ISE</title>
</head>

sessione.php:

PHP:
<?php
	session_start();
	
	if(!$_SESSION['user_id']){
?>
		<script language="javascript">
			document.location.href="login.php";
		</script>}
<?php
	}else
		$id_utente = $_SESSION['user_id'];
?>

E' proprio una struttura classica, usata da chiunque... Non vedo il motivo di quel warning, uffa...

Mi aiutate?
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.046
150
63
PR
www.borgo-italia.it
ciao
l'include è come se tu facessi il copia incolla del codice scritto nel file da includere, in pratica il tuo index.php è come se fosse

PHP:
<head> 
      <?php 
            session_start(); 
     
    if(!$_SESSION['user_id']){ 
?> 
        <script language="javascript"> 
            document.location.href="login.php"; 
        </script>} 
<?php 
    }else 
        $id_utente = $_SESSION['user_id']; 
        include("include/foglicss.html"); 
    ?> 
    <title>Pagina di supporto ADV-ISE</title> 
</head>
come puoi notare session_start() viene dopo <head>, per cui il warning

ti conviene fare
index.php
PHP:
<?php
session_start();
?>
<head> 
      <?php 
        include("include/sessione.php"); 
        include("include/foglicss.html"); 
    ?> 
    <title>Pagina di supporto ADV-ISE</title> 
</head>
sessione.php
PHP:
<?php      
    if(!$_SESSION['user_id']){ 
?> 
        <script language="javascript"> 
            document.location.href="login.php"; 
        </script>} 
<?php 
    }else 
        $id_utente = $_SESSION['user_id']; 
?>
 
Ultima modifica:
Discussioni simili
Autore Titolo Forum Risposte Data
F [MySQL] Warning 1265 data truncated for column... MySQL 5
B Warning: mysql_connect(): Access denied for user 'DIREZIONE'@'81.88.55.179' (using password: YES) PHP 6
G [PHP] Warning: Cannot modify header information - headers already sent by PHP 3
G [PHP] Problema - Warning: session_start() [function.session-start] PHP 9
G Warning: mysql_num_rows() che problema è? PHP 3
P Warning: mysqli_query() expects parameter 1 to be mysqli PHP 2
C ERRORE: Warning: move_uploaded_file()... come risolverlo? PHP 1
JackIlPazzo Warning: Invalid argument supplied for foreach() PHP 1
N warning su sessione PHP 2
F Warning: Invalid argument supplied for foreach() PHP 3
A Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given PHP 17
L Problema messaggio d'errore -Warning: mysqli_num_rows() expects parameter 1 to be mysqli_ etc etc... PHP 2
pup3770 Su Mac funziona - su windows da warning PHP 9
E Warning: session_start() PHP 1
P Warning: mysql_num_rows() expects parameter 1 to be resource, array given in PHP 9
A Warning: mysql_result() expects parameter 1 to be resource, boolean given MySQL 2
I Warning: Division by zero in Joomla 0
S Help : Warning: mail() [function.mail] PHP 2
H Warning: Cannot modify header information... PHP 6
P Warning email() PHP 116
catellostefano CLASSE PHP Warning: mysql_fetch_assoc() expects parameter 1 to be resource PHP 2
Frank10 Problema w3c warning HTML5 -.-" HTML e CSS 5
neo996sps Warning su redirect della pagina PHP 9
M Warning: mysql_query() expects parameter 2 to be resource, boolean given PHP 3
catellostefano Problema per richiamare file xml -- Warning: DOMDocument::load() [domdocument.load]: PHP 0
L Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in .... PHP 2
L Warning: Cannot modify header information - headers already sent by... PHP 9
H Warning: session_start() [function.session-start]: Cannot send session cache limiter PHP 8
S errore warning mysql_ferch_array() e mysql_free_result() PHP 5
A Warning strano PHP 2
JellyBelly Warning Uso Rename PHP 2
M Warning: session_start(): Cannot send session cache... ???? PHP 5
W Warning: main(./WEB-INF/etc/config.php): PHP 3
M Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in PHP 6
M Warning: Cannot modify header information - headers already sent by (output started a PHP 1
C problema con un warning PHP 0
S Trasferire dati sulle pagine del sito PHP 7
stefanomessina [MySQL] Dubbio sulle PROCEDURE MySQL 0
G [PHP] Operazioni sulle stringhe PHP 2
V [Guida]: ho dubbi sulle Join MySQL 13
S funzioni per calcoli sulle date PHP 4
C BLOG sulla musica e sulle band Altri Annunci 1
C BLOG sulla musica e sulle band Annunci servizi di Social Media Marketing 0
C [cerco collaboratori] BLOG sulla musica e sulle band Offerte e Richieste di Lavoro e/o Collaborazione 4
C BLOG sulla musica e sulle band HTML e CSS 2
T "Storiella" sul modello logico e concettuale e sulle query SQL MySQL 4
D [SERVIZIO FB] PageRush.net Pubblica Automaticamente i contenuti sulle tue pagine di facebook! Annunci servizi di Social Media Marketing 0
D Effetti sulle immagini con jQuery jQuery 4
L Devo pagare le tasse sulle donazioni PayPal? Leggi, Normative e Fisco 2
M Effetto rollover sulle immagini: immagine selezionata? Javascript 0

Discussioni simili