Monday, April 18, 2011

.htaccess file – Increase execution time, session expiry time and file upload size limit



php_value post_max_size 5M

php_value upload_max_filesize 5M

php_value memory_limit 300M

php_value max_execution_time 259200

php_value max_input_time 259200

php_value session.gc_maxlifetime 1200




php_value memory_limit 300M - Set higher default php_value memory_limit in .htaccessupload_max_filesize 5M - it increases default upload limit. The default upload limit is 2MB. the above htaccess increase increases file limit 2mb to 5 mbphp_value max_execution_time: Set the number of seconds a script is allowed to run. If this is reached,the script returns a fatal error. The default limit is 30 seconds or, if itexists, the max_execution_time value defined in the configuration file. Ifseconds is set to zero, no time limit is imposed.php_value session.gc_maxlifetime: The session.gc_maxlifetime only sets the age of the session files that will be deleted whengarbage collection runs.If you have a busy web site with a lot of sessions being created, garbage collection willrun based on session.gc_probability/session.gc_divisor. Despite this being called"probability" I tested this and it is strictly a count. Using the defaultgc_probability/gc_divisor of 1/100, this means that garbage collection will run every 100new sessions (Edit: Actually this occurs within the session_start() coding and would countre-started sessions as well) and delete any existing session files that are older than thesession.gc_maxlifetime. There is no file locking on the session files, so active sessionfiles will be deleted and things like users getting logged out will occur.If this is on shared hosting and the session files are all kept in the default location andsomeone else is using a smaller session.gc_maxlifetime or a more frequentgc_probability/gc_divisor, then any of the session files will get deleted based on thelowest value of gc_maxlifetime and the most frequent gc_probability/gc_divisor.You need to increase session.gc_maxlifetime or make session.gc_divisor larger and if this ison shared hosting, set session.save_path to be a location within your web space.

No comments:

Post a Comment