By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,602 Members | 1,507 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,602 IT Pros & Developers. It's quick & easy.

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

P: n/a
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\apache2\htdocs\thegain\index.php:4) in
c:\apache\apache2\htdocs\thegain\index.php on line 19

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

c:\apache\apache2\htdocs\thegain\index.php:4) in
c:\apache\apache2\htdocs\thegain\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_register("custom_sessid"); // 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($insert);

?>

....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
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
RG

"mr_burns" <bi******@yahoo.co.uk> wrote in message
news:65**************************@posting.google.c om...
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\apache2\htdocs\thegain\index.php:4) in
c:\apache\apache2\htdocs\thegain\index.php on line 19

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

c:\apache\apache2\htdocs\thegain\index.php:4) in
c:\apache\apache2\htdocs\thegain\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_register("custom_sessid"); // 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($insert);

?>

...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

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

Jul 17 '05 #2

P: n/a
"RG" <Me@NotTellingYa.com> wrote in message news:<3f***********************@mercury.nildram.ne t>...
"mr_burns" <bi******@yahoo.co.uk> wrote in message
news:65**************************@posting.google.c om...
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\apache2\htdocs\thegain\index.php:4) in
c:\apache\apache2\htdocs\thegain\index.php on line 19

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

c:\apache\apache2\htdocs\thegain\index.php:4) in
c:\apache\apache2\htdocs\thegain\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_register("custom_sessid"); // 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($insert);

?>

...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

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

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
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.