Pawan_Agarwal Posted July 30, 2013 Share Posted July 30, 2013 I am working on a code that will help me in creating and maintaining the session on webpage. When the customer visits the page the session must become active and increase the counter by one. I am able to do that. But, when the customer visits that page again, session_start() has been called again and it provided a warning. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\index.php:13) in C:\xampp\htdocs\counter.php on line 2 so, what can I do to omit this warning After visiting the page the session gets created and it does not updates further but it gives the above listed warning , looking for a quick answer ................. Link to comment https://forums.phpfreaks.com/topic/280633-session-is-displaying-error-after-execution/ Share on other sites More sharing options...
0xMatt Posted July 30, 2013 Share Posted July 30, 2013 It looks like you've already posted a topic about this issue. You may want to reconsider your approach to this entire situation. However, to answer your question, you can suppress warnings generated by a function by placing this @ symbol in front of it, e.g: @session_start(); You can also handle this by modifying your error reporting levels. In the long run, this is never the best practice. Just suppressing errors because of a poor design concept isn't recommended, ever. Link to comment https://forums.phpfreaks.com/topic/280633-session-is-displaying-error-after-execution/#findComment-1442637 Share on other sites More sharing options...
PravinS Posted July 30, 2013 Share Posted July 30, 2013 write your session_start() function at top of your page, there should not be any single space, character etc.(basically any output) before session_start() function Link to comment https://forums.phpfreaks.com/topic/280633-session-is-displaying-error-after-execution/#findComment-1442638 Share on other sites More sharing options...
Pawan_Agarwal Posted July 30, 2013 Author Share Posted July 30, 2013 the code is not displaying error , however , the condition is true and it is updating database, it is not considering it as false, here is the code for you....... if(!isset($_SESSION['__name__'])) { global $total; $_SESSION['__name__']="Guest"; $total=$total+1; $result = mysql_query("UPDATE visitors SET TOTAL='$total'") ; } the session creates successfully and it updates the value in database as soon as i refresh the page............i don't know why it is not halting when there is no error or warning in the code........... Link to comment https://forums.phpfreaks.com/topic/280633-session-is-displaying-error-after-execution/#findComment-1442642 Share on other sites More sharing options...
PaulRyan Posted July 30, 2013 Share Posted July 30, 2013 Please show us the code from counter.php and the top 20 or so lines from index.php. Link to comment https://forums.phpfreaks.com/topic/280633-session-is-displaying-error-after-execution/#findComment-1442649 Share on other sites More sharing options...
Pawan_Agarwal Posted July 31, 2013 Author Share Posted July 31, 2013 I rearrange the code and now it is working fine.............I am thankful to all guys participated in helping me... Link to comment https://forums.phpfreaks.com/topic/280633-session-is-displaying-error-after-execution/#findComment-1442773 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.