Problem with session_start

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ray Torres

    Problem with session_start

    I get a warning and cannot start a session. I understand from reading
    through the documentation and other posts that session_start must occur in
    the php script before any HTML tags or output to the browser. In my
    script, the session_name and session_start are the first two lines in
    thescript; so I can't see what the problem could be.

    I have used sessions on other pages in a similar fashion (in the same web
    project, on the same server) and do not have any problems.

    I would greatly appreciate if anyone has any ideas of what could be causing
    the problem.

    The warning as reported by the web server is as follows:
    ----------
    Warning: Cannot send session cookie - headers already sent by (output
    started at /home/parking2/secure_html/ControlPanel/adminCtrl.php:2 ) in
    /home/parking2/secure_html/ControlPanel/adminCtrl.php on line 4

    Warning: Cannot send session cache limiter - headers already sent (output
    started at /home/parking2/secure_html/ControlPanel/adminCtrl.php:2 ) in
    /home/parking2/secure_html/ControlPanel/adminCtrl.php on line 4
    -----------

    // The first lines of my php script source code are as follows:

    <?php
    session_name("r eport_page");
    session_start() ;

    include '../vars.php';

    // Get variables from forms:
    if (!empty($HTTP_P OST_VARS)) while(list($nam e, $value) =
    each($HTTP_POST _VARS)) $$name = $value;

    show_page_heade r();

    if ($logout)
    {
    $_SESSION['time'] = 0;
    }



    if(!($_SESSION['time'] > (time() - 3600) ))
    {
    do_login();
    exit;
    }

    // end php code snippet ------------------------------------------



  • Alvaro G Vicario

    #2
    Re: Problem with session_start

    *** Ray Torres wrote/escribió (Tue, 14 Sep 2004 19:41:16 -0700):[color=blue]
    > <?php
    > session_name("r eport_page");
    > session_start() ;[/color]

    If session_start() is in line 4, then you have a blank line in the
    beginning of the file. That counts as output.



    --
    -- Álvaro G. Vicario - Burgos, Spain
    -- Thank you for not e-mailing me your questions
    --

    Comment

    Working...