PHP - Warning: session_start(): Cannot send session

 
Vista:

Warning: session_start(): Cannot send session

Publicado por Jorge Alejandro (1 intervención) el 29/05/2018 05:08:05
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/sutdcona/public_html/adminplantel/adminplantel.php:1) in /home/sutdcona/public_html/adminplantel/adminplantel.php on line 2


este es mi codigo

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
<?php
session_start();
if (@!$_SESSION['plantel']) {
	header("Location:index.php");
}else if ($_SESSION['rol']==1) {
	header("Location:index.php");
}else if ($_SESSION['rol']==3) {
	header("Location:index.php");
}else if ($_SESSION['rol']==4) {
	header("Location:index.php");
}else if ($_SESSION['rol']==5) {
	header("Location:index.php");
}else if ($_SESSION['rol']==6) {
	header("Location:index.php");
}else if ($_SESSION['rol']==7) {
	header("Location:index.php");
}else if ($_SESSION['rol']==8) {
	header("Location:index.php");
}else if ($_SESSION['rol']==9) {
	header("Location:index.php");
}else if ($_SESSION['rol']==10) {
	header("Location:index.php");
}else if ($_SESSION['rol']==11) {
	header("Location:index.php");
}else if ($_SESSION['rol']==12) {
	header("Location:index.php");
}else if ($_SESSION['rol']==13) {
	header("Location:index.php");
}else if ($_SESSION['rol']==14) {
	header("Location:index.php");
}else if ($_SESSION['rol']==15) {
	header("Location:index.php");
}else if ($_SESSION['rol']==16) {
	header("Location:index.php");
}else if ($_SESSION['rol']==17) {
	header("Location:index.php");
}else if ($_SESSION['rol']==18) {
	header("Location:index.php");
}else if ($_SESSION['rol']==19) {
	header("Location:index.php");
}else if ($_SESSION['rol']==20) {
	header("Location:index.php");
}else if ($_SESSION['rol']==21) {
	header("Location:index.php");
}else if ($_SESSION['rol']==22) {
	header("Location:index.php");
}else if ($_SESSION['rol']==23) {
	header("Location:index.php");
}else if ($_SESSION['rol']==24) {
	header("Location:index.php");
}else if ($_SESSION['rol']==25) {
	header("Location:index.php");
}else if ($_SESSION['rol']==26) {
	header("Location:index.php");
}else if ($_SESSION['rol']==27) {
	header("Location:index.php");
}else if ($_SESSION['rol']==28) {
	header("Location:index.php");
}else if ($_SESSION['rol']==29) {
	header("Location:index.php");
}else if ($_SESSION['rol']==30) {
	header("Location:index.php");
}else if ($_SESSION['rol']==31) {
	header("Location:index.php");
}else if ($_SESSION['rol']==32) {
	header("Location:index.php");
}else if ($_SESSION['rol']==33) {
	header("Location:index.php");
}
?>
 
<html>
<head>
    <meta charset="utf-8">
    <title>SUDTCONALEP</title>
 
     <link rel="stylesheet" href="css/index1.css">
 
     <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="icon" href="imagenes/sut.jpg">
      </head>
 
      </body>
 
</html>

espero me puedan ayudar se los agradeceria
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 Alejandro
Val: 1.634
Plata
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Warning: session_start(): Cannot send session

Publicado por Alejandro (839 intervenciones) el 29/05/2018 16:41:23
  • Alejandro se encuentra ahora conectado en el
  • chat de PHP
session_start(); debe ser la primer linea antes de cualquier cosa, toma en cuenta si tu archivo es include o require.

Por ejemplo si en adminplantel.php si es tu primer linea pero tienes un index.php como esto
1
2
header('Content-Type: text/html; charset=utf-8');
include('adminplantel.php');

Lo anterior equivale a lo siguiente donde session_start no es la primer linea.
1
2
header('Content-Type: text/html; charset=utf-8');
session_start();

Por cierto es mejor un array
1
2
$aRoles = array(1=>'rol1.php','rol2.php','roln.php');
header("Location:$aRoles[$_SESSION['rol']];");
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar