SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2001
    Location
    Hamburg, Germany
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I am a newbie to php programming so I tried to type up the code that Kevin Yank used in his article "Managing users with PHP Sessions and MySQL" (Article ID 319)

    Most of it works fine except for the bit about cookies. I get the following error messages when using session_start() :

    Cannot send session cookie - headers already sent by (output started at c:\server\apache\htdocs/courseworks/display.php:3) in accesscontrol.php on line 2

    Has anyone got a quick solution for this problem? Any ideas what might cause such a error message, I don't even get what it is trying to tell me...

    Thanks for your help,

    Frank
    That' it.

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, you cannot have any html or whitespcae or output above your opening session_start(); call.

    Example

    ========Top of file===========
    <html>
    <head>
    </head>
    <body>
    <?
    session_start();

    or

    ========Top of file===========


    <?
    session_start();

    or

    ========Top of file===========


    <?
    echo "Some data";
    session_start();


    Will cause that error
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Member
    Join Date
    May 2001
    Location
    Hamburg, Germany
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks

    Hey, it worked, thanks a lot!

    My file started with the following line

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    which I had to delete.


    So where do I put this line now, or do I just forget about it?
    That' it.

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Either delete it or put it after you call session_start();

    Something like


    <?
    session_start();
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <?
    //Rest of php here
    ?>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •