Jump to content

[SOLVED] session cookies


sprint10s

Recommended Posts

This is the error im getting

 

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/www/standridgemotorsports.com/sponsor.php:11) in /home/www/standridgemotorsports.com/auth.inc.php on line 2

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/www/standridgemotorsports.com/sponsor.php:11) in /home/www/standridgemotorsports.com/auth.inc.php on line 2

 

Warning: Cannot modify header information - headers already sent by (output started at /home/www/standridgemotorsports.com/sponsor.php:11) in /home/www/standridgemotorsports.com/auth.inc.php on line 7

You are being redirected to the login screen!

(If your browser does not support this, click here)

 

below here is the auth file code

<?php 
session_start();
if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1) {
// Do Nothing
} else {
$redirect = $_SERVER['PHP_SELF'];
header("Refresh: 5; URL=login.php?redirect=$redirect");
echo "You are being redirected to the login screen!<br>";
echo "(If your browser does not support this, " . 
	"<a href=\"login.php?redirect=$redirect\">click here</a>)";
die();
}
?>

 

can anyone help me figure out whats going on.  basically i got two other files a login.php and sponsor.php i want to protect the sponsor.php page so they have to login with the right credentials in order to see the contents of the sponsor.php page.

 

thanks for any help

 

 

Link to comment
Share on other sites

<?php

session_start();

if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1) {

// Do Nothing

} else {

$redirect = $_SERVER['PHP_SELF'];

echo "You are being redirected to the login screen!<br>";

echo "(If your browser does not support this, " .

"<a href=\"login.php?redirect=$redirect\">click here</a>)";

header("Refresh: 5; URL=login.php?redirect=$redirect");

die();

}

?>

 

You can not echo after you send header()

 

Read: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html

Link to comment
Share on other sites

:facewall:

 

You can not echo after you send header()

You have it backwards.

 

All headers MUST be sent prior to any output.  This means all calls to header() and all functions that send or modify headers as a side-effect, such as session_start(), MUST occur before any output has gone to the browser.

 

You can not echo anything, not even a blank line, to the browser before the headers are sent.

Link to comment
Share on other sites

:facewall:

 

You can not echo after you send header()

You have it backwards.

 

All headers MUST be sent prior to any output.  This means all calls to header() and all functions that send or modify headers as a side-effect, such as session_start(), MUST occur before any output has gone to the browser.

 

You can not echo anything, not even a blank line, to the browser before the headers are sent.

 

Ah, that is so - my bad.

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.