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
https://forums.phpfreaks.com/topic/170354-solved-session-cookies/
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

: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.

: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.

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.