•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 401,646 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,701 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1577 | Replies: 13 | Solved
![]() |
•
•
Join Date: Oct 2007
Location: Penang Island, Malaysia
Posts: 170
Reputation:
Rep Power: 1
Solved Threads: 2
php Syntax (Toggle Plain Text)
<?php // This is the logout page for the site. // Include the configuration file for error management and such. require_once ('mysql_connect.php'); // Set the page title and include the HTML header. $page_title = 'Logout'; include ('./includes/header.html'); $MM_redirectLoginFailed = "index.html"; $MM_redirecttoReferrer = true; // If no first_name variable exists, redirect the user. if (isset($_SESSION['first_name'])) { // Start defining the URL. //$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. //if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { //$url = substr ($url, 0, -1); // Chop off the slash. //} // Add the page. //$url .= '/index.html'; ob_end_clean(); // Delete the buffer. //header("Location: $url"); //header("Location: index.html"); echo "<script type='text/javascript'>location.href='$MM_redirectLoginSuccess';</script>"; exit(); // Quit the script. } else { // Logout the user. $_SESSION = array(); // Destroy the variables. session_destroy(); // Destroy the session itself. //session_unset(); setcookie (session_name(), '', time()-300, '/', '', 0); // Destroy the cookie. } // Print a customized message. echo "<h3>You are now logged out.</h3>"; include ('./includes/footer.html'); ?>
I've tried this code and the errors are:
Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in C:\xampp\htdocs\cycle\logout.php on line 34
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\cycle\includes\header.html:7) in C:\xampp\htdocs\cycle\logout.php on line 36
Please help.
"I might not be the BEST but I'm not like the REST!"
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
•
•
•
•
Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in C:\xampp\htdocs\cycle\logout.php on line 34
That means you are trying to destroy a session that doesn't exist.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Oct 2007
Location: Penang Island, Malaysia
Posts: 170
Reputation:
Rep Power: 1
Solved Threads: 2
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Re-authenticating User Problem (PHP)
- PHP MySQL problem (PHP)
- timeout session problem (JSP)
- Facing the problem on "RedirectFromLoginPage" (VB.NET)
- inet20099 Problem (Viruses, Spyware and other Nasties)
- Netscape 7.1, Hotmail login problem - cookies 'disabled" (Windows NT / 2000 / XP / 2003)
- computer lagging...hijack this log, please help (Viruses, Spyware and other Nasties)
- Mystery IE Session Freezes (Web Browsers)
- Possible CWS problem (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: display the data into listbox
- Next Thread: Hidden variable in php



Cool ! congrats !
Linear Mode