For some reason, on occasion, I get the following fatal error from my PHP code when running on a shared server:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\HostingSpaces[username][subdomain]\wwwroot\index.php on line 8
And that line is just:
session_regenerate_id();
Might this problem be from the code being hosted on a shared server and resources not being available? Or is there some other cause for this problem?
Since it’s a shared server, I can’t change any PHP settings.
EDIT:
The only line before line 8 are a few require_once lines for model objects. The only other line is session_start().
I checked my PHP settings and it states that the session.save_handler is files for both the local and master values. Since it is using files, might the problem be trying to read and write from the disk?
I think your problem might be a performance and resource issue as you suspect, but I find it strange that it has only stopped on line 8. I’d guess that the chances could be high if the rest of the code was very minimal.
Have you tried altering the code in an attempt to get the timeout to occur on a different line? For instance, you could try adding
sleep(25);and see if the fatal timeout occurs on that line instead.Also, are you certain that you cannot set the maximum execution time limit? I would suspect that even if you cannot alter the shared php.ini, you could set the
max_execution_timethrough one of these other options:php_value max_execution_timedirective in an .htaccessfile
set_time_limitin your codeini_setandmax_execution_timein your codeI believe the value/argument for
max_execution_timeis in seconds, and if you set it to 0 (zero) then NO execution time limit will be used. (Whether you consider it safe to use zero or not is up to you.)