Jump to content


Photo

Problems with php sessions


  • Please log in to reply
5 replies to this topic

#1 cybercrypt13

cybercrypt13
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 03 April 2006 - 01:58 PM

We had a website that worked perfectly up until Friday. Since Friday when we open a page we get the following error. No code changes within the site took place so this has to be some sort of configuration problem but I don't know what.

Can any help?

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/softekso/public_html/tbamu/functions.php:68) in /home/softekso/public_html/tbamu/main/body_header.php on line 2


Thanks

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 03 April 2006 - 02:19 PM

It is becuase something has been outputted near line 68 in functions.php and body_header.php is starting a session around line 2.

#3 cybercrypt13

cybercrypt13
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 03 April 2006 - 03:08 PM

Thats not an answer but a restatement of the obvious. As I stated, nothing has changed in our source code so I don't see how it could possibly have problems. Something has changed in the configuration on the server somewhere that has caused this problem. its the only thing that makes sense. I've checked the global property in php.ini and its turned on.

However, there are more than one php.ini file. Can anyone tell me how to determine which one is being used by php?

THanks,

#4 cybercrypt13

cybercrypt13
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 03 April 2006 - 03:58 PM

I need to clarify a few things now that I better understand the problem.

I have a function.php that stores a bunch of functions one of which connects to the db. This function accesses a session var to determine the name of the db and its always worked perfectly for years.

Now, upon trying to access the sessionvar it is finding it to be an empty string, despite the fact that the variable exists on other pages. I have the session_start(); line as the only line directly after <? and again, none of this code has changed so it has to be something on the server thats caused this to act this way.

Any ideas?

#5 thirdearth

thirdearth
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 18 December 2008 - 08:56 PM

Usually that issue, at least in my experience, is because you are sending a header function after something else is already being outputted.  All header functions have to be processed before any code *even blank space* can be outputted.

http://us3.php.net/m...tion.header.php

There are 2 ways that I know of to fix this.  First one is to make sure that you are only using the header function at the top of all processed pages, before any other code is ran.  The second, and easier, way to handle this is ob_start and ob_end_flush functions.

http://us.php.net/ob_start

If you use those on the page, then everything between them will buffer before any code is outputted.  As to why it just started happening, I can't tell you.  Did anyone change your configuration of PHP?  My guess is that there was some sort of error reporting option that was turned off before and someone turned on.  I had the same issue when I swapped a PHP-driven site from a host to my personal web server and I used output buffering to fix it.

#6 thirdearth

thirdearth
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 18 December 2008 - 09:00 PM

Wow, I just noticed that there was a sticky regarding this issue.  Guess I should look around before I go posting replies that have probably been answered a thousand times.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users