problem with session_start() - cannot send session cookie/cache limiter

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

    problem with session_start() - cannot send session cookie/cache limiter

    Hi, i am getting the following errors when running my php script:



    Warning: Cannot send session cookie - headers already sent by (output
    started at

    c:\apache\apach e2\htdocs\thega in\index.php:4) in
    c:\apache\apach e2\htdocs\thega in\index.php on line 19

    Warning: Cannot send session cache limiter - headers already sent
    (output started at

    c:\apache\apach e2\htdocs\thega in\index.php:4) in
    c:\apache\apach e2\htdocs\thega in\index.php on line 19



    ....the script i am trying to run is as follows:



    <?php

    session_start() ; //start session to get session variables

    //this code is to check if a custom session variable exists. if none,
    create one.
    if (!isset($custom _sessid)) {

    $custom_sessid = md5($_SERVER['REMOTE_ADDR'] . " " . date("Y-m-d
    H:i:s")); // create a session id
    session_registe r("custom_sessi d"); // register newly ceated session
    variable

    }

    $indate = date("Y-m-d H:i:s");
    $page_id = 1; //each page will have its own number

    $insert = "INSERT INTO tracker (tracker_id, page_id, indate,
    custom_sessid) values (null, $page_id,

    '$indate', '$custom_sessid ')";
    $result = mysql_query($in sert);

    ?>

    ....the purpose of the tracker table is to log the session id and the
    page number to have a complete log of pages visited by a user
    (identified by their session id) to allow me to build some form of
    site statistics but for some reason i am getting an error (see above).

    does anybody know why this is?? cheers

    burnsy
  • RG

    #2
    Re: problem with session_start() - cannot send session cookie/cache limiter


    "mr_burns" <bissatch@yahoo .co.uk> wrote in message
    news:651c6ea9.0 310090406.77caf 3fa@posting.goo gle.com...[color=blue]
    > Hi, i am getting the following errors when running my php script:
    >
    >
    >
    > Warning: Cannot send session cookie - headers already sent by (output
    > started at
    >
    > c:\apache\apach e2\htdocs\thega in\index.php:4) in
    > c:\apache\apach e2\htdocs\thega in\index.php on line 19
    >
    > Warning: Cannot send session cache limiter - headers already sent
    > (output started at
    >
    > c:\apache\apach e2\htdocs\thega in\index.php:4) in
    > c:\apache\apach e2\htdocs\thega in\index.php on line 19
    >
    >
    >
    > ...the script i am trying to run is as follows:
    >
    >
    >
    > <?php
    >
    > session_start() ; //start session to get session variables
    >
    > //this code is to check if a custom session variable exists. if none,
    > create one.
    > if (!isset($custom _sessid)) {
    >
    > $custom_sessid = md5($_SERVER['REMOTE_ADDR'] . " " . date("Y-m-d
    > H:i:s")); // create a session id
    > session_registe r("custom_sessi d"); // register newly ceated session
    > variable
    >
    > }
    >
    > $indate = date("Y-m-d H:i:s");
    > $page_id = 1; //each page will have its own number
    >
    > $insert = "INSERT INTO tracker (tracker_id, page_id, indate,
    > custom_sessid) values (null, $page_id,
    >
    > '$indate', '$custom_sessid ')";
    > $result = mysql_query($in sert);
    >
    > ?>
    >
    > ...the purpose of the tracker table is to log the session id and the
    > page number to have a complete log of pages visited by a user
    > (identified by their session id) to allow me to build some form of
    > site statistics but for some reason i am getting an error (see above).
    >
    > does anybody know why this is?? cheers
    >
    > burnsy[/color]


    Hey Burnsy,
    Are there any spaces before your <?php tag.
    If there are these will be outputed, thus sending a header.
    RG



    Comment

    • mr_burns

      #3
      Re: problem with session_start() - cannot send session cookie/cache limiter

      "RG" <Me@NotTellingY a.com> wrote in message news:<3f8575eb$ 0$65592$65c6931 4@mercury.nildr am.net>...[color=blue]
      > "mr_burns" <bissatch@yahoo .co.uk> wrote in message
      > news:651c6ea9.0 310090406.77caf 3fa@posting.goo gle.com...[color=green]
      > > Hi, i am getting the following errors when running my php script:
      > >
      > >
      > >
      > > Warning: Cannot send session cookie - headers already sent by (output
      > > started at
      > >
      > > c:\apache\apach e2\htdocs\thega in\index.php:4) in
      > > c:\apache\apach e2\htdocs\thega in\index.php on line 19
      > >
      > > Warning: Cannot send session cache limiter - headers already sent
      > > (output started at
      > >
      > > c:\apache\apach e2\htdocs\thega in\index.php:4) in
      > > c:\apache\apach e2\htdocs\thega in\index.php on line 19
      > >
      > >
      > >
      > > ...the script i am trying to run is as follows:
      > >
      > >
      > >
      > > <?php
      > >
      > > session_start() ; //start session to get session variables
      > >
      > > //this code is to check if a custom session variable exists. if none,
      > > create one.
      > > if (!isset($custom _sessid)) {
      > >
      > > $custom_sessid = md5($_SERVER['REMOTE_ADDR'] . " " . date("Y-m-d
      > > H:i:s")); // create a session id
      > > session_registe r("custom_sessi d"); // register newly ceated session
      > > variable
      > >
      > > }
      > >
      > > $indate = date("Y-m-d H:i:s");
      > > $page_id = 1; //each page will have its own number
      > >
      > > $insert = "INSERT INTO tracker (tracker_id, page_id, indate,
      > > custom_sessid) values (null, $page_id,
      > >
      > > '$indate', '$custom_sessid ')";
      > > $result = mysql_query($in sert);
      > >
      > > ?>
      > >
      > > ...the purpose of the tracker table is to log the session id and the
      > > page number to have a complete log of pages visited by a user
      > > (identified by their session id) to allow me to build some form of
      > > site statistics but for some reason i am getting an error (see above).
      > >
      > > does anybody know why this is?? cheers
      > >
      > > burnsy[/color]
      >
      >
      > Hey Burnsy,
      > Are there any spaces before your <?php tag.
      > If there are these will be outputed, thus sending a header.
      > RG[/color]


      hi,
      ive figured out the problem. i didnt have the start_session() command
      at the top of the page (whoops). i completely forgot that it had to go
      there. thanks anyway.

      burnsy

      Comment

      Working...