How to reset row in PHP?

PHP Sessions - how to reset?

  • Hello, When I send output to the browser in PHP, e.g. print "hello world"; This basically starts a session in PHP. If, after printing Hello World, I have something like this: session_start(); Then I get the following error message: Warning: Cannot send session cache limiter - headers already sent... I would like to know if there is some way to "reset" the session somehow so that I can still use PHP's session handling functions even after sending output to the browser. I've been using PHP for about 4 years, and have used sessions for about 2 years, although in the past I have always been able to get around this problem by putting session handling functions before any browser output. At the moment, however, I'm faced with a scenario where I cannot do this. Thanks, Darren

  • Answer:

    Hi, What the commentor suggest below will work, but there is a slightly better way, and one I use quite a bit. The ob_start() and ob_end_flush() http://www.php.net/manual/en/function.ob-start.php http://www.php.net/manual/en/function.ob-end-flush.php example: <?PHP ob_start(); // Stop Header Action // if($ad=="google"){Redirect("add_page.html",0); exit;} print "hello world"; ob_end_flush(); // Let Header Happen // ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html dir="LTR"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> ... and what ever else you want to do here with the page. You can build all of your needed output variables inside those two, and when you are done, the flush sends the output to the browser. Thanks, webadept-ga

g8z-ga at Google Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.