0

This is important because I have a e-commerce site and I can't have a browser time out in the middle of payment processing! I have set_time_limit(0) in my PHP script so the script doesn't time out. But what about the user's browser? How long until it times out?

Note: data is returned to the browser only near the end of the script - most of the time involved is server work.

Also, is it possible for me to change the browser timeout length?

I need info for IE6+, Chrome, Opera, Safari, and Firefox. Thanks.

Hope4You
  • 1,927
  • 4
  • 21
  • 45
  • I believe this question is answered here: http://stackoverflow.com/questions/5798707/browser-timeouts – Jamie Feb 28 '12 at 20:35
  • Not really. Although the link given http://support.microsoft.com/kb/813827 says IE is 1 minute the link http://support.microsoft.com/kb/181050 says 60 minutes. I need clarification. – Hope4You Feb 28 '12 at 20:37

2 Answers2

2

Why not use AJAX and let the process run in the background, but report once every x seconds / minutes back to the browser?

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
  • This may be what I need to do. How do I make the PHP script report every x seconds back to the browser, so it doesn't time out? Do I just have to add an `echo 'return text';` line of code? – Hope4You Feb 28 '12 at 20:58
  • You can turn it the other way around. Let a javascript on the page request the status every 5 seconds for example. – PeeHaa Feb 28 '12 at 21:05
0

Why not make the script execute as a cron job, and then save the report either in a table or as a file in whatever format you need?

Timeouts are going to vary not just by browser, but could vary from user to user. Firefox for example you can use about:config to change the different types of timeouts.

eomer
  • 397
  • 1
  • 3
  • 14
  • The script must finish instantly so people can get their digital downloads. – Hope4You Feb 28 '12 at 20:39
  • 1
    @Hope4You So, one Ajax call kicks off the process and another repeating one polls to see if the process has completed. I wouldn't trust the browser timeout, even if specified, not to bite you here. – Andrew Feb 28 '12 at 21:13
  • @Andrew How do I do the "polls to see if the process has completed"? – Hope4You Feb 29 '12 at 00:42
  • @Hope4You That is the substance of PeeHaa's answer. You would have to set up a lightweight web service (which can just be a PHP script, for example) that you can call from Ajax, that will tell the browser when the server-side operation has completed. A full description would be beyond the scope of a comment, but the Javascript setInterval function just might be involved. – Andrew Feb 29 '12 at 18:06