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

"Cannot modify header information" error

mikek12004
100+
P: 200
In top of my index I include funcs.php which is :
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function GetCartId()
  3. {
  4.     //if user logged on use username as identification, else use coockie for anonymous user    
  5.     if ($_SESSION['loggedon']==1)
  6.     {
  7.     $a=$_SESSION['username'];
  8.     }            
  9.     else
  10.     {
  11.     // This part generates an encrypted string and will set it as a cookie using set_cookie. This will also be used as the cookieId    //field in the cart table
  12.         if(isset($_COOKIE["cartId"]))
  13.         {
  14.             return $_COOKIE["cartId"];
  15.         }
  16.         else
  17.         {
  18.             // There is no cookie set. We will set the cookie
  19.             // and return the value of the users session ID
  20.  
  21.             session_start();
  22.             setcookie("cartId", session_id(), time() + ((3600 * 24) * 30));
  23.             $a=session_id();
  24.  
  25.  
  26.         }
  27.     }
  28.     return $a;
  29. }
  30. function mssql_sec($a)
  31. {
  32. $a=str_replace("'","''",$a);
  33. $a=str_replace(";","",$a);
  34. return $a;
  35. }
  36. function mssql_sec2($a)
  37. {
  38. $a=str_replace("'","''",$a);
  39. //$a=str_replace(";","",$a);
  40. return $a;
  41. }
  42. ?>
  43.  
then later at the index I include basket.php which calls GetCartId() and the explorer shows the message
"Cannot modify header information - headers already sent by (output started at /var/www/html/generalm/demo/index.php:31) in /var/www/html/generalm/demo/nimda/funcs.php on line 22"
any help?
PS before including the funcs.php I have sesion_start()
Oct 21 '08 #1
Share this Question
Share on Google+
1 Reply


mikek12004
100+
P: 200
The whole point is to identify a user so I can recognise him in future visits, even if I get the error the func works and a unique id (which is $a) is retrived which I can use it to display various info for him, any idea how can I disable the stupid error and why since it works this error is diplayed?
Oct 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.