SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cookie deletion problem

    I'm having a bit of a problem with deleting a cookie. I have this code:
    PHP Code:
    if ($_GET['logout'] == "true")
    {
        
    $_SESSION = array();
        
    session_destroy();
        
    setcookie("loggedin""TRUE"time()-(3600 24));//the line with the problems

    for some reason, it is giving a "headers already sent" error. What is wrong?

  2. #2

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any spaces before this code block?

  3. #3
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, it goes like this:
    PHP Code:
    <?php
    include('common.php');
    include(
    'config.php');
    include(
    'prefs.php');

    $dir $_GET['dir'];
    $dirsize dirsize("{$rootpath}{$username}");
    $trueuser str_replace($rootpath''$dir);

    if (
    $_GET['logout'] == "true")
    {
        
    $_SESSION = array();
        
    session_destroy();
        
    setcookie("loggedin""TRUE"time()-(3600 24)); //EEEEVIL!!!

  4. #4

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I meant spaces before the
    PHP Code:
    <?php
    Any possibility your includes do some output? Any error messages popping up?

  5. #5
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HEre is the error:

    Warning: Cannot modify header information - headers already sent by (output started at /home/me/public_html/common.php:6) in /home/me/public_html/viewfiles.php on line 14
    Logout failed- cookies were not cleared!
    You will be redirected to your user control panel in three seconds.
    If the problem persists, please contact the webmaster.

    (The last three lines were the die code)
    And there are no spaces before the <?php

  6. #6

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by geniusgoalie
    HEre is the error:

    Warning: Cannot modify header information - headers already sent by (output started at /home/me/public_html/common.php:6) in /home/me/public_html/viewfiles.php on line 14
    Logout failed- cookies were not cleared!
    You will be redirected to your user control panel in three seconds.
    If the problem persists, please contact the webmaster.

    (The last three lines were the die code)
    And there are no spaces before the <?php

  7. #7
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    These are the top six lines in the common.php page though... it makes no sense
    PHP Code:
    <?php
    session_start
    ();
    header("Cache-control: private");
    include(
    'config.php');
    include(
    'prefs.php');
    echo 
    "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"style.css\">";

  8. #8

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The "echo" my friend, the "echo"

    This is the actual output.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •