My code is generating a warning and I can't figure it out . . .
Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot|PortalApps\functions.php:10) in C:\Inetpub\wwwroot\PortalApps\functions.php on line 294
Line 294:
setcookie("cookieId", session_id(), time() + ((3600 24) 30));
Code in page calling function (at the very top of script):
<?php
session_start();
require_once ('functions.php'); // file which has GetCookieId()
$session_id = GetCookieId();
echo $session_id;
?>
FUNCTION:
<?php
function GetCookieId()
{
if(isset($COOKIE["cookieId"]))
{
return $COOKIE["cookieId"];
}
else
{
session_start();
setcookie("cookieId", session_id(), time() + ((3600 24) 30));
return session_id();
}
}
?>
Any help greatly appreciated!!