Jump to content

session_start errors


Obi1-Cannabis
 Share

Recommended Posts

hi, this is kind of weird and is driving me crazy i'm finding at my php_error_log.txt that sometimes there are one of this two errors when calling session_start()sometimes everything is ok, other times i get a Maximum execution time of 30 seconds exceeded in <SERVER>\app.php on line 13 and some other times i get this:

session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at <SERVER>\www\cesto\index.php:1) in <SERVER>\app.php on line 13
but this doesn't seem possible since all my code until the session_start is:
<?php	/*error_reporting(E_ALL);	ini_set('display_errors', '1');*/	//configuracao do header p3p privacy	header('P3P:CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT"');		/*header("Cache-Control: no-cache, must-revalidate");	header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");*/		//Configuracoes de Sessao	session_cache_limiter('none');	session_start();

does anyone have any idea why this might be happening?

Link to comment
Share on other sites

The error message is telling you what the problem is. There is output on index.php on line 1 that is causing the headers to be sent. The code in app.php raises the error because the headers were already sent. The problem is the index.php file that is sending the output on line 1.

Link to comment
Share on other sites

This seems so obvious that the fact jsg did not mention it makes me think I am wrong, but doesn't the header function send a header, therefore causing the "headers already sent" error?

Link to comment
Share on other sites

It just adds a header to the list of headers to send, it doesn't cause them all to immediately go out though. You can send multiple headers out, like when downloading a file.
That's what I had originally thought, but your post here seemed to imply otherwise.
Link to comment
Share on other sites

Yeah, this line isn't exactly accurate:

All the header functions does is send a header to the browser.
Technically, the header function causes a header to be sent to the browser, it doesn't actually send it though.That's my understanding, at least. It might also in fact be the case that the header function does actually send the header, but only if no non-header data has been sent (i.e., only if the only output has been headers so far). Regardless, using the header function once does not preclude using it a second time.
Link to comment
Share on other sites

Timeout usually occurs if you have an infinite loop.There are two types of UTF-8: UTF-8 with BOM (Byte Order Mark) and UTF-8 on its own.If the UTF-8 has a BOM it sometimes may be interpretted has having a couple of characters as the beginning of the file, so you should make sure your editor saves the file without a BOM.

Link to comment
Share on other sites

There are two types of UTF-8: UTF-8 with BOM (Byte Order Mark) and UTF-8 on its own.If the UTF-8 has a BOM it sometimes may be interpretted has having a couple of characters as the beginning of the file, so you should make sure your editor saves the file without a BOM.
ok thanks for clarification :)
Timeout usually occurs if you have an infinite loop.
yes, but how come session_start() be considerided as an infinite loop? i'm prety sure it can't
Link to comment
Share on other sites

session_start shouldn't timeout. If it does, and it's using the default options for sessions, the only reason I can think of is that it's trying to open or create a session file and for whatever reason the OS is making it wait instead of either creating the file or failing. I haven't heard of something like that happening though, I also haven't heard of session_start causing a timeout. Also, "none" is not a valid value for the cache limiter.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...