Jump to content

Recommended Posts

Hi guys,

Everything was working fine earlier but I made some changes to the layout and now I'm getting this error.

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/thegamer/public_html/PHP/members.php:3) in /home/thegamer/public_html/PHP/members.php on line 4

 

ERROR: You must be logged in to view this

 

This is the code

 

<html>
<head>
<?php
session_start();
if (!$_SESSION['auth'] == 1) {
    // check if authentication was performed
    // else die with error
    die ("ERROR: You must be logged in to view this");
}
?>
<link rel="stylesheet" type="text/css" href="css.css" />
<title>Aarons Site</title>
</head>
<body>
<div id="navigation">
  <p class="headings">Navigation</p>
  <p><a href="index.html">Home</a></p>
  <p><a href="newuser.html">Register</a></p>
  <p><a href="login.html">Log In</a></p>
  <p><a href="members.php">Members Area </a></p>
</div>
<div id="content">Content Section
	<form action="logout.php" method="post">
<input type="submit" value="Logout" />
</form>


</div>
<div id="banner">
  <p>Banner</p>
  <p> </p>
  <p> </p>
</div>
</body>
</html>

 

Its meant to just display either welcome your logged in or, ERROR: You must be logged in to view this.

 

 

Link to comment
https://forums.phpfreaks.com/topic/125193-solved-php-session-error/
Share on other sites

You cannot have any form of output before the use of session_start().

 

Change

<html>
<head>
<?php
session_start();
if (!$_SESSION['auth'] == 1) {
    // check if authentication was performed
    // else die with error
    die ("ERROR: You must be logged in to view this");
}
?>

to

<?php
session_start();
if (!$_SESSION['auth'] == 1) {
    // check if authentication was performed
    // else die with error
    die ("ERROR: You must be logged in to view this");
}
?>
html>
<head>

 

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.