By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,180 Members | 1,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,180 IT Pros & Developers. It's quick & easy.

Warning: session_start(): Cannot send session cookie - headers already sent by

P: n/a
Bob
Seem to have a problem ending a session. I get the following message.
Warning: session_start(): Cannot send session cookie - headers already
sent by (output started at
C:\xitami\xitami-24\app\webpages\logout.php:9) in
C:\xitami\xitami-24\app\webpages\logout.php on line 10

Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at
C:\xitami\xitami-24\app\webpages\logout.php:9) in
C:\xitami\xitami-24\app\webpages\logout.php on line 10

You have been logged off, you must re-login to use the system.
Log In

The code is as follows.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Logged Out</title>
</head>

<body>
<?php
session_start();
session_unset();
session_destroy();

//unset($HTTP_SESSION_VARS['valid_user']);
//unset($HTTP_SESSION_VARS['privlevel']);
//session_destroy();

echo '<h3>You have been logged off, you must re-login to use the
system.</h3>';
echo '<a href="log_in.php">Log In</a><br />';
?>

</body>
</html>
I am using Homesite4.5 and saving the file as "pc" format. The
webserver is Xitami.

Help would be appreciated.
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
>Seem to have a problem ending a session. I get the following message.

Warning: session_start(): Cannot send session cookie - headers already
sent by (output started at
You may not output ANYTHING before calling session_start(), (or
other functions that need to send headers, like cookie setting).
Nada. Zip. Nothing. Put your HTML, DOCTYPE, blank lines, single
spaces, etc. *after* calling session_start().

Gordon L. Burditt
C:\xitami\xitami-24\app\webpages\logout.php:9) in
C:\xitami\xitami-24\app\webpages\logout.php on line 10

Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at
C:\xitami\xitami-24\app\webpages\logout.php:9) in
C:\xitami\xitami-24\app\webpages\logout.php on line 10

You have been logged off, you must re-login to use the system.
Log In

The code is as follows.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Logged Out</title>
</head>

<body>
<?php
session_start();
session_unset();
session_destroy();

//unset($HTTP_SESSION_VARS['valid_user']);
//unset($HTTP_SESSION_VARS['privlevel']);
//session_destroy();

echo '<h3>You have been logged off, you must re-login to use the
system.</h3>';
echo '<a href="log_in.php">Log In</a><br />';
?>

</body>
</html>
I am using Homesite4.5 and saving the file as "pc" format. The
webserver is Xitami.

Help would be appreciated.

Jul 17 '05 #2

P: n/a
While the city slept, Bob (cl****@qualitythink.com) feverishly typed...
Seem to have a problem ending a session. I get the following message.

Warning: session_start(): Cannot send session cookie - headers already

[etc]

You cannot have any output before the session (including normal HTML
output). Try re-organising as follows;

<?php
session_start();
session_unset();
session_destroy();

//unset($HTTP_SESSION_VARS['valid_user']);
//unset($HTTP_SESSION_VARS['privlevel']);
//session_destroy();
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Logged Out</title>
</head>

<body>
<h3>You have been logged off, you must re-login to use the system.</h3>';
<p><a href="log_in.php">Log In</a></p>
</body>
</html>

.... A couple of non-php points. It is probably time for you to consider
coding the HTML 4.01 Strict doctype. Why have you used H3 to mark up the
"You have been logged off..." text? Where are the first and second level
headings that should precede it?

Hope that helps,
Nige

--
Nigel Moss
http://www.nigenet.org.uk
Mail address not valid. ni***@DOG.nigenet.org.uk, take the DOG. out!
In the land of the blind, the one-eyed man is very, very busy!
Jul 17 '05 #3

P: n/a
Bob
Thanks to both of you for the help.
Jul 17 '05 #4

P: n/a
While the city slept, Bob (cl****@qualitythink.com) feverishly typed...
Thanks to both of you for the help.


Your welcome. :-)

Cheers,
Nige

--
Nigel Moss
http://www.nigenet.org.uk
Mail address not valid. ni***@DOG.nigenet.org.uk, take the DOG. out!
In the land of the blind, the one-eyed man is very, very busy!
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.