SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Session problem

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Session problem

    Hi,
    When starting session_start() after ob_start(); there is always some unwanted crap code before the real output. When session_start() is before ob_start() it's ok.

    Why?

  2. #2
    Non-Member St.'s Avatar
    Join Date
    Nov 2004
    Location
    Cloud #9
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    case ob_start() starts writing all outputs into memory.
    with ob_flush() you can send all of code from memory writed after ob_start().
    but session_start() is starting session. It means not only send header to user, but it fetchs $_SESSION variables.
    How I understend, if you start session_start() before ob_start(), $_SESSION variables in realy will fetch after ob_flush().

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem was solved as follows;

    PHP Code:
    <?php

    ob_start
    ();

    //.......

    ob_start();
    session_start();
    ob_end_flush();

    //.......

    ob_end_flush();

    ?>
    But there is still this question; Why?


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
  •