Run PHP function after 5 min from the page done load


I want to run PHP code update a row in my database when the user did 5 min in the page. can I do this check for the time spent in PHP or I have to do it in javascript
and how can i do so.

and am getting this error every time i try to set new cookie .

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\public_html\inc\mainheader.php:7) in C:\xampp\htdocs\public_html\functions\dynamic-function.php on line 876


Hi @AwadGorg!

Please add…

php_value output_buffering on

…to /public_html/.htaccess. If the file does not exist, create one and append the upper string :wink:


am already have this code in my .htaccess and am working in my localhost


i took all my functions and but it before the <!doctype html> to be the first headers that sent in the page some of my code work when i did this but other still giving me the same error


In this case you may need to use ob_start() / ob_end_flush()


I used the code you suggested

ob_start() / ob_end_flush()
iand nothing happend still the same problem


I put the set-cookie at line one to be the first header sent by still the same problem

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\public_html\inc\mainheader.php:17) in C:\xampp\htdocs\public_html\inc\mainheader.php on line 1

this starting to become unsolvable


Maybe .htaccess ain’t working on your local system?


this rewrite rule works fine in my localhost but the php buffering has no effect

php_value output_buffering on

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]


Try placing session_start(); at the top of your code


Make sure you send absolutely no header: header() after any other text data. That’s the issue.


print('love you!');

header('some header here..');


<?php header('some header here.'); ?>


<?php header('....'); ?>



but if i go with the right method the div below the header wont work cause it will redirect the user that mean ever code below the header function will stop.
and what i want is to set a cookie not to send a header

and write now am setting the cookie at line 1 as the irst header in the document
but am still getting the same error

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\public_html\inc\mainheader.php:7 ''i have the doctype in this lin) in C:\xampp\htdocs\public_html\functions\dynamic-function.php on line 1


and i already have a session start in line 1


i have a better idea if i created the cookie with JavaScript and handle it with my PHP
code will this gonna effect my code


Try php_flag output_buffering on

_flag instead of _value

I don’t recommend you to use ob_start and ob_end_flush functions because it makes your scripts messy.

.htacces code should fix your problem :wink:


will it worked thanks very much. but I already used javascript to set my cookies but am sure that this will be helpful in the future. thanks again