PHP - problema con sesiones

 
Vista:

problema con sesiones

Publicado por leandro (9 intervenciones) el 12/09/2012 21:07:56
hola gente, feliz dia.
les comento tengo problemas cuando quiero iniciar una session, utilizo php 5.
quisiera saber una forma correcta de usar sessione, ya sea abriendo o creando y luego cerrando sin que me aparezca el cartel:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/seghma/public_html/agregarnota.php:6) in /home/seghma/public_html/agregarnota.php on line 64

A que se debe dicho cartel?.
les paso el codigo fuente para que lo chequeen t me comenten.

Muchas Gracias.
Leandro

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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>SEGHMA Seguridad,Higiene Y Medio Ambiente</title>
<link rel="stylesheet" type="text/css" href="NiftyCube/NiftyLayout.css" media="screen">
<script type="text/javascript" src="NiftyCube/niftycube.js"></script>
<script type="text/javascript" src="NiftyCube/NiftyLayout.js"></script>
<link rel="stylesheet" type="text/css" href="NiftyCube/niftyCorners.css" media="screen">
 
<script src="NiftyCube/jquery-latest.js"></script>
  <script type="text/javascript">
function showHint(str,pass)
{
var xmlhttp;
if (str.length==0)
  {
  document.getElementById("resultados").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && (xmlhttp.status==200  || window.location.href.indexOf("http")==-1))
    {
    document.getElementById("resultados").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","gethint.php?u="+str.value+"&p="+pass.value,true);
xmlhttp.send();
}
  </script>
 
</head>
<body>
<div id="rs">
<A HREF="http://facebook.com/SEGHMA" title="Seguinos..."><img src="imagenes/facebook.png" style="border:0;"></a>
</div>
<div id="header">
<img src="imagenes/Logo SEGHMA.jpg" align="center" width="40%" height="40%">
<div id="menu">
<ul id="nav">
<li id="home"><a href="index.php">Inicio</a></li>
<li id="cont"><a href="noticias.php">Noticias</a></li>
<li id="prod"><a href="personal.php">Personal</a></li>
<li id="serv"><a href="servicios.php">Servicios</a></li>
<li id="cont"><a href="empresas.php">Empresas</a></li>
<li id="home"><a href="fotos.php">Fotos</a></li>
<li id="cont"><a href="mapa.php">Mapa</a></li>
<li id="cont"><a href="contacto.php">Contacto</a></li>
</ul>
</div>
</div>
<div id="container">
<div id="content">
 
<?php
session_start();
//echo $_SESSION['usuario'];
if (isset($_SESSION['usuario'])){
echo "<h1><font color='#03284B'>Agregar Noticia </font><font size='2'><a title='Cerrar Sesion' href='cerrarsesion.php'> Cerrar</a></font></h1>";
	echo "<form method='POST' action='agregarnota.php?op='2'>
		  <p><input name='razonsocial' size='37' type='text' value='Titulo de la Noticia'></p>
          <p><textarea rows='7' name='mensaje' cols='61'>Contenido de la Noticia</textarea></p>
		  <p><input value='Enviar' name='B1' type='submit'></p>
		  </form>";
}
else{
echo "<h1><font color='#03284B'>Login</font></h1>";
	echo "<form action='#'>
			<table style='border-collapse: collapse;' width='50%' border='0' bordercolor='#111111' cellpadding='0' cellspacing='0'>
			<tbody><tr>
				<td width='10%' align='right'>
				<p align='left'><font size='2'>usuario:</font><input name='usuario' size='20' style='float: left;'></p></td>
				<td width='10%'>
				<p align='left'><font size='2'>contraseña:</font><input name='password' size='20' style='float: left;' type='password'></p></td>
				<td rowspan='2' width='109%'><input value='Login' onclick='showHint(usuario,password)' name='B3' type='button'></td>
			</tr>
			<tr>
				<td width='28%' align='right'>&nbsp;</td>
				<td width='28%'>&nbsp;</td>
			</tr>
			</tbody>
			</table>
			</form>";
}
?>
 
 
 
<div id="resul" style="">
<span id="resultados" style=""></span>
</div>
 
</div>
 
<div id="footer">
<p><font color="#F6F9FC">SEGHMA 2012</font></p>
 
</div>
 
</div>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

problema con sesiones

Publicado por xve (6935 intervenciones) el 12/09/2012 22:10:24
Tienes que poner la instrucción session_start() encima de todo de la web, antes de enviar ningun código al navegador... algo así:
1
2
3
4
5
6
7
8
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>SEGHMA Seguridad,Higiene Y Medio Ambiente</title>
....
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar