Jump to content

Do something every X seconds


squiblo

Recommended Posts

Hello, what I want to do is call a function every X seconds, I can do this when staying on 1 page without navigating off, but my problem is that I want to call the function every X seconds even if the user is moving from page to page and I do not know how this can be done.

 

For example I want to call the function every 20 seconds, I am on the homepage for 10 seconds, then move to the help page, then I only have to wait another 10 seconds before the function is called.

 

Any help?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/212188-do-something-every-x-seconds/
Share on other sites

In general, 20s is not a long time...is there a reason it can't just be reset on page load? It would be far easier for you to just start the process over on a new page load...my first suggestion is for you to reconsider whether it's really necessary to carry over a timeout of that short of time from page to page.  if it is something you absolutely need to do, then as AlexWD mentioned, I'd also store the last call time in a cookie and draw from that from page to page.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.