|
session_gcPerform session data garbage collection Description
int session_gc
( void
)
session_gc is used to perform session data GC(garbage collection). PHP does probability based session GC by default. Probability based GC works somewhat but it has few problems. 1) Low traffic site's session data may not be deleted within preferred duration. 2) High traffic site's may have too frequent GC. 3) GC is performed on the user's request and the user will experience GC delay. Therefore, it is recommended to execute GC periodically for production systems. e.g. Use "cron" for UNIX like systems. Make sure to disable probability based GC by setting session.gc_probability to 0. Return Values
session_gc returns number of deleted session
data for success, Old save handlers do not return number of deleted session data, but only success/failure flag. If this is the case, number of deleted session data became 1 regardless of actually deleted data. Examples
Example #1 session_gc example for task managers like cron
<?php Example #2 session_gc example for user accessible script
<?php |