# php session problem



## myha (Oct 26, 2009)

edit: fixed by setting "session.cache_limiter = public " in php.ini

Hi,

I am having some issues on my apache server....

I am trying to login against AD directory which works fine, and after that I am writing the $_SESSION variables and redirecting user to actual requested page - and here is the problem.

I am using exactly the same code on some other Gentoo-based server and it works without problems, but on freebsd I receive the following errors:

```
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/local
/www/apache22/data/login/index.php:9) in /usr/local/www/apache22/data/login/index.php on line 96

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/www/apache22/data/login/index.php:9) in 
/usr/local/www/apache22/data/login/index.php on line 100
```

Here is the php code, before it is just html:

```
if(($_GET['action'] == "logout"))
{
		session_start();
		session_destroy();
	 	print '<p style="text-align:center;">You have logged out.</p>';
}
if((!empty($myusername)) and (!empty($mypassword))) 
{
	//include login script
	require_once('adLDAP.php');
	$adldap = new adLDAP();

	//user authentication
	$authUser = $adldap->authenticate($myusername, $mypassword);
	
	if($authUser == true)
	{
		session_start();
		$_SESSION['myusername'] = $myusername;
		$_SESSION['mypassword'] = $mypassword;	
		$_SESSION['time'] = time();
		header("Location:../index.php");
	}
	else 
	{
  		print '<p>User authentication Failed!</p>';	
		print '<div class="notice">You must use your domain login!</div>';
  	}
}
?>
```

index.php:9 (line 9 of the code)

```
<style type="text/css">
	@import url("http://x.x.x.x/css/common.css");
</style>
```
line 96 and 100 are session_start and header.

I also tried moving session_start(); to beginning of the document but it does not help...

This server is inside jail.

Any ideas?


----------

