Solved

Login Script Help Cant Logout

Posted on 2004-08-19
5
404 Views
Last Modified: 2008-01-09
hello this is what I have collected untill now, I have learned a little bit of database and cookies,
but I keep getting an error in the "logout.php" when I Login I mark "Remember me next time"
and from the main.php is where I  logout

here is the warning I warning or error
Warning: Cannot modify header information - headers already sent by (output started at /home/www/html/notes1/login.php:147) in /home/www/html/notes1/logout.php on line 7 and 8

I have upload the script to my friend's site here it is the code http://www.astrotarotonline.com/user/xtry/help_logout.rar

I have tried too many things to get it right but im getting crazy now, and decided to look for the professional help.
0
Comment
Question by:Xtry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Expert Comment

by:iwarner
ID: 11849279
Maybe something in the include files is creating an output to the screen, this means that you cannot set cookies / edit sessions when this happens.

try this - it seems the includes are unecessary anyway as there are no reference to these in the code.

<?php
      session_start();

// DELETE OLD COOKIES

      if (isset($_COOKIE['KraCookieName']) && isset($_COOKIE['KraCookiePass']))
            {
            setcookie ("KraCookieName", "", time() - 60*60*24*30, "/");
            setcookie ("KraCookiePass", "", time() - 60*60*24*30, "/");
            }

      unset($_SESSION['username']);
      unset($_SESSION['password']);

// kill session variables

      $_SESSION = array(); // reset session array
      session_destroy();   // destroy session.

      if ($logged_in == 0)
            {
            die('You are not logged in so you cannot log out.');
            }

      echo "<h1>Logged Out</h1>\n";
      echo "You have successfully <b>logged out</b>. Back to <a href=\"main.php\">main</a>";
?>
0
 
LVL 6

Accepted Solution

by:
merwetta1 earned 500 total points
ID: 11849305
The error is caused by a couple of extra line feeds at the end of your login.php script. When you include login.php from main.php, the line feeds are being output to the browser and shutting off any further header info (like cookies and sessions). It's an easy mistake.

To fix...open login.php with your text editor and delete everything after the last closing php tag "?>", save, repost, and you will not get the modify header warning. If you need help beyond that, please post.
0
 
LVL 4

Expert Comment

by:sint4x
ID: 11850560
Yeah, you cannot edit the headers after you display the contents of the page
0
 

Expert Comment

by:Dennis_Nielsen
ID: 11850640
I agree, but I don't fully understand why you want the login-script included in the logout script...?

I't should be safe to remove the include files in logout.php.

<?php

if ($logged_in == 0) {
      die('You are not logged in so you cannot log out.');
}

unset($_SESSION['username']);
unset($_SESSION['password']);
// kill session variables
$_SESSION = array(); // reset session array
session_destroy();   // destroy session.

   echo "<h1>Logged Out</h1>\n";
   echo "You have successfully <b>logged out</b>. Back to <a href=\"main.php\">main</a>";

?>
0
 

Author Comment

by:Xtry
ID: 11851552
thanks a lot for the help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question