Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.