• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

PHP sessions

mjquilly

Golden Member
I'm having problems w/ my logout routine for my website. Here it is:
--------------------------------------------------------------------
<?php
session_start();
if(isset($userid))
{
session_unregister('userid');
session_unregister('passwd');
echo "You are now logged out";
}
else
{
echo "You are not logged in...";
}
session_destroy();

--------------------------------------------------------------------

I get the following message when "session_start()" is called:

--------------------------------------------------------------------
Warning: Cannot send session cache limiter - headers already sent (output started at /home/sites/site194/web/logout.php:5) in /home/sites/site194/web/logout.php on line 7
--------------------------------------------------------------------

The user IS actaully logged out, i just don't like that error message. I know i can just put a "@" in front of the call to session_start and it won't show up, but i'd rather know why this message is there. Am I doing something wrong?
 
Do you have the <html> and/or <body> tags in the file before the php script actually starts? If so, that's what's causing the error. The header information needs to be sent before everything else. Try moving the <html> to an echo command after you open the session, and that should solve the warning that you're getting. I ran into something similar with a couple login/logout scripts that I wrote for the admin portion of my work's website, deleting the cookie set by logging in. I had to delete the cookie before having the <html> "displayed".

Edit: I'm guessing that the session_open(); command is on line 7 of your source, and that the <html> is on line 7, right before the <?php tag starts. That's just going by what the error message states.

JW
 
Back
Top