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

Cannot send session cache limiter - headers already sent

P: 2
I get this msg: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /web/www/frac/users/s/students/katalog/brukere/login.php:2) in /web/www/frac/users/s/students/katalog/brukere/login.php on line 3

when I use this code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. if($_GET['loggut']=="1")
  4. {
  5. session_start();
  6. session_destroy(); 
  7. header("Location: medlem.php"); 
  8. exit(); 
  9. else 
  10. session_start(); 
  11.  
  12.  
  13. require("innstillinger/konfigurasjon.php"); 
  14.  
  15. if(file_exists("installer.php")) 
  16. echo <<<__HTML_END
  17. exit(); 
  18.  
  19. if(!empty('$_SESSION[b_brukernavn]') && 
  20. !empty('$_SESSION[b_login_key]')) 
  21. $b_brukernavn = '$_SESSION[b_brukernavn]'; 
  22. $b_login_key = '$_SESSION[b_login_key]'; 
  23.  
  24. $sql = mysql_query("select * from $tabell_brukere where 
  25. brukernavn = '$b_brukernavn' AND login_key = 
  26. '$b_login_key' AND status <> '0'"); 
  27.  
  28. $antall_funnet = mysql_num_rows($sql); 
  29.  
  30. if($antall_funnet==1) 
  31. header("Location: medlem.php"); 
  32. exit(); 
  33.  
  34. if(isset($_POST[logginn])) 
  35. foreach( $_POST as $key => $value ) 
  36.  ${$key} = htmlspecialchars($value, ENT_QUOTES); 
  37. if(!empty($brukernavn) && !empty($passord)) 
  38. $md_passord = md5($passord); 
  39.  
  40. $sjekk_bruker = mysql_query("select id from 
  41. $tabell_brukere where passord='$md_passord' and 
  42. brukernavn='$brukernavn'"); 
  43. $funnet=mysql_num_rows($sjekk_bruker); 
  44.  
  45. if($funnet<>1) 
  46. sleep(3); 
  47. print "Beklager, gyldig bruker ble ikke funnet"; 
  48. else 
  49. function tilfeldig_key($lengde) 
  50. $utvalg = 
  51. "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr 
  52. stuvwxyz"; 
  53. for($i=0;$i<$lengde;$i++) 
  54. $streng .= $utvalg{rand(0,35)}; 
  55. return $streng; 
  56. $tidspunkt = date("d-m-Y H:i:s"); 
  57. $login_session_kode = date("YmdHis").tilfeldig_key(15); 
  58. $login_session_md_kode = md5($login_session_kode); 
  59.  
  60. $oppdater_db = mysql_query("update $tabell_brukere set 
  61. login_key='$login_session_md_kode', 
  62. login_tid='$tidspunkt', count=count+1 where 
  63. brukernavn='$brukernavn' AND passord='$md_passord'"); 
  64.  
  65. if($oppdater_db) 
  66. '$_SESSION[b_brukernavn]'= $brukernavn; 
  67. '$_SESSION[b_login_key]'= $login_session_md_kode; 
  68.  
  69. header("Location: medlem.php"); 
  70. print "Innlogging vellykket, <a href='$brukerside'>Gå 
  71. videre til medlemsområdet --></a>"; 
  72. exit(); 
  73. else 
  74. print "Innlogging ikke mulig, prøv igjen"; 
  75. else 
  76. print "Både brukernavn og passord må fylles ut"; 
  77.  
  78. // start logg inn skjema 
  79. echo <<<__HTML_END
  80. <form action="login.php" method="post"> 
  81.  
  82. Brukernavn 
  83.  
  84. <input type="text" name="brukernavn" 
  85. value="$brukernavn" size="30" /> 
  86.  
  87. Passord 
  88.  
  89. <input type="password" name="passord" value="" 
  90. size="30" /> 
  91.  
  92. <input type="submit" name="logginn" value="Logg inn" /> 
  93.  
  94. </form> 
  95.  
  96. <a href="glemt_pass.php">Glemt passord ?</a> 
  97.  
  98.  
  99. __HTML_END;
  100. }
  101. ?>


Can someone please help and help me to fix this?
Sep 5 '07 #1
Share this Question
Share on Google+
4 Replies


P: 2
I did remove the space and its working no more msg, but i just get a white side whitout anything on it!!! where the login box and password box?:S

help.
Sep 5 '07 #2

nathj
Expert 100+
P: 938
I get this msg: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /web/www/frac/users/s/students/katalog/brukere/login.php:2) in /web/www/frac/users/s/students/katalog/brukere/login.php on line 3

when I use this code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. if($_GET['loggut']=="1")
  4. {
  5. session_start();
  6. session_destroy(); ?>
Hi arashi,

The session_start(); line must be the very first thing the page executes. It has to run before anything else is set. This is what your error means.

Move the session_start() to the very top, so that it appears there and only there and you should be up and running - or at least have this error fixed.

Cheers
nathj
Sep 5 '07 #3

ak1dnar
Expert 100+
P: 1,584
When posting source codes please use the correct CODE tags, as It is help us to read the code lines easily.
[code=php]
Sep 5 '07 #4

pbmods
Expert 5K+
P: 5,821
Heya, Arashi. Welcome to TSDN!

Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).

If you're getting a blank page, your script is probably generating an error. Check out this article to find out what is going on.
Sep 5 '07 #5

Post your reply

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

Browse more PHP Questions on Bytes