Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Login Script Help Cant Logout

Posted on 2004-08-19
5
Medium Priority
?
407 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

722 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