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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.