Jump to content

Warning: session_start() [function.session-start]: Cannot send session cache


gilestodd

Recommended Posts

I am having trouble resolving an error.

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/s519970/public_html/header.php:27) in /home/s519970/public_html/admin/login.php on line 2

 

What I can gather is I can't use "header (Location: 'admin.php')" after i've used session_start(). I have tried to replace the header (Location: 'admin.php') with this:

 

                echo "<script>document.location.href='admin.php'</script>";

echo "<script>'Content-type: application/octet-stream'</script>";

 

I've been trying to read up on solutions but haven't been able to get it sorted. If anyone can offer some advice that would be greatly appreciated as im new to php.

 

<?php
  session_start();
  if(isset($_SESSION['user']))

                echo "<script>document.location.href='admin.php'</script>";
	echo "<script>'Content-type: application/octet-stream'</script>";
?>

<div id="loginform">

<form action="dologin.php" method="post">
	<table>
		<tr>
			<td><span>Username:</span></td>
			<td><input type="text" name="username" /></td>
		</tr>
		<tr>
			<td><span>Password:</span></td>
			<td><input type="password" name="password" /></td>
		</tr>
		<tr>
			<td colspan="2" align="right"><input type="submit" name="login" value="Login" /></td>
		</tr>
	</table>
</form>

</div>

 

I have tried using require_once('yourpage.php'); before my <head></head> tags in the header document where I've specified the html information but this doesn't seem to work. I've been advised to use ob_start("ob_gzhandler"); but I am not sure how to implement this.

 

Any advice is greatly appreciated!

 

Link to comment
Share on other sites

What I can gather is I can't use "header (Location: 'admin.php')" after i've used session_start(). I have tried to replace the header

 

No, you can. You can't use it after outputting something though. The error tells you you're output started in 'header.php' at line 27.

 

See this sticky.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.