Solved

How do I get rid of "Cannot send session cache limiter - headers already sent "?

Posted on 2009-07-10
11
290 Views
Last Modified: 2012-05-07
I'm using flash/xml site template from flashden. while the site is under construction I have added a login module using sessions so that only the guys who are working on the project can view the pages.
My problem is that after login, when my page is redirected to the home page, I get the warning as follows:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent....
I have gone over the same problem posted on our Experts Exchange and tried some solutions offered in vain. The session_start() is on the first line after the <?php delimiter and ther is also no white space anywhere...
Can someone please help me to solve this issue? Thanks in advance.
<?php session_start(); 
 
if($_SESSION['admin'] && $_SESSION['admin'] != ""){
//do nothing
}else{
echo "<script language=\"JavaScript\">location.replace(\"index.html\"); </script>";
}
	
	?><!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" xml:lang="en" lang="en">
<head>
// Rest of the code

Open in new window

0
Comment
Question by:786aslamkhan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +2
11 Comments
 
LVL 11

Expert Comment

by:BrianMM
ID: 24821946
Might seem trivial but try it like this.
<?php
session_start();
...stuff

Open in new window

0
 
LVL 7

Expert Comment

by:fluglash
ID: 24821960
post some code from the beginning of your index.html, please
0
 
LVL 11

Expert Comment

by:BrianMM
ID: 24821962
failing that, it's a problem saving the file... most likley text encoding of whatever editor you are using.
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 12

Expert Comment

by:jet-black
ID: 24821978
If you are using UTF-8 encoding,
uncheck "Include Unicode Signature (BOM)".
before saving.
0
 
LVL 9

Expert Comment

by:pmessana
ID: 24822663
Much like Brian said but I would go a bit further to keep it clean and ensure that it is getting parsed correctly.
<?php
 
session_start(); 
 
if($_SESSION['admin'] && $_SESSION['admin'] != ""){
  //do nothing
}else{
  echo "<script language=\"JavaScript\">location.replace(\"index.html\"); </script>";
}
        
?>
<!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" xml:lang="en" lang="en">
<head>
// Rest of the code

Open in new window

0
 

Author Comment

by:786aslamkhan
ID: 24824765
Thanks BrianMM for your response. I tried putting session_start() on the second line as suggested- does not work.

Thanks jet-black I tried saving the file by unchecking the "Include Unicode Signature (BOM)". Does not work.

Thanks pmessana for your suggestion.

Thanks fluglash!

I have attached the whole file, so you all can have a look.

Thanks again BrianMM, jet-black, pmessana and fluglash.


<?php session_start(); 
 
if($_SESSION['some_name'] && $_SESSION['some_name'] != ""){
//do nothing
}else{
echo "<script language=\"JavaScript\">location.replace(\"index.html\"); </script>";
}
	
	?><!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Author" content="author">
<meta name="keywords" content="keywords" />
<meta name="description" content="desc" />
<title>Title</title>
 
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript" src="swfaddress.js"></script>
<script type="text/javascript" src="swffit.js"></script>
 
 
<style type="text/css">
	/* hide from ie on mac \*/
	html {
		height: 100%;
		overflow: hidden;
	}
	
	#flashcontent {
		height: 100%;
	}
	/* end hide */
 
	body {
		height: 100%;
		margin: 0;
		padding: 0;
		background-color: #0d0d0d;
	}
	p {
 
	font-size: 10px;
	font-family: Verdana;
	line-height:17px;
	color:#999999;
	
}
#apDiv1 {
	position:absolute;
	left:454px;
	top:58px;
	width:197px;
	height:37px;
	z-index:1;
}
#apDiv2 {
	position:absolute;
	left:442px;
	top:481px;
	width:261px;
	height:51px;
	z-index:2;
}
#apDiv3 {
	position:absolute;
	left:443px;
	top:114px;
	width:267px;
	height:53px;
	z-index:1;
}
#apDiv4 {
	position:absolute;
	left:500px;
	top:440px;
	width:262px;
	height:52px;
	z-index:1;
}
#Layer1 {
	position:absolute;
	left:447px;
	top:176px;
	width:53px;
	height:21px;
	z-index:1;
}
.style3 {
	color: #FFFFFF;
	font-family: Verdana, Arial, Helvetica, sans-serif;
}
#Layer2 {
	position:absolute;
	left:372px;
	top:68px;
	width:101px;
	height:22px;
	z-index:1;
}
</style>
<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
//-->
</script>
</head>
<body onload="MM_popupMsg('Right_Click Mouse  to select Full Screen option.\rIt\'s Recommended!')">
<div id="flashcontent"> 
 
  <p style="color:#999999">
    You need Adobe Flash Player 9.0.115 to visit this site.</p>
  <hr width="360" align="left"/>
 <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="" /></a></p>
</div>
    
 	 
	
<script type="text/javascript">
   	var flashvars = {};
	flashvars.url_config="xml/configuration_site.xml";
	flashvars.initServices=true;
	var params = { allowfullscreen:true,allowScriptAccess:"always" };
	var attributes = { id:'flashObject' }; // give an id to the flash object
	
	swfobject.embedSWF("index.swf", "flashcontent", "100%", "100%", "8", "expressInstall.swf", flashvars, params,attributes);
	//swffit.fit("flashObject",900,620);
</script>
	     
 
 
</body>
</html>

Open in new window

0
 
LVL 12

Expert Comment

by:jet-black
ID: 24824945
786aslamkhan,

There is no problem about your code.
The error you are facing is resulting because of there is hidden characters before <?php tag.

You can download
RapidPHP http://www.blumentals.net/rapidphp/
Then select Options->Show Hidden Characters

And remove the hidden characters then save the file.

Also,
you can attach the zip file and we remove the hidden characters.
0
 
LVL 12

Accepted Solution

by:
jet-black earned 500 total points
ID: 24825067
or simply download
http://www.crimsoneditor.com/download/cedt370r.exe

open your file,
then choose Document->Encoding Type->UTF-8 Encoding(w/o BOM)

And save your file.
0
 
LVL 12

Expert Comment

by:jet-black
ID: 24825106
0
 

Author Closing Comment

by:786aslamkhan
ID: 31602010
Thanks a ton jet-black! it worked! my problem solved. AND I HAVE LEARNED FROM YOU.
THANK YOU SO VERY MUCH!!!!!!!!!!!
0
 
LVL 12

Expert Comment

by:jet-black
ID: 24826563
Welcome :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question