shlomikalfa Posted May 15, 2008 Share Posted May 15, 2008 hi there, Q. How to make server auto' remove session files when expired ?! current Session variables in PHP: Session Support enabled Registered save handlers files user sqlite Registered serializer handlers php php_binary wddx Directive Local Value Master Value session.auto_start Off Off session.bug_compat_42 On On session.bug_compat_warn On On session.cache_expire 180 180 session.cache_limiter nocache nocache session.cookie_domain no value no value session.cookie_httponly Off Off session.cookie_lifetime 0 0 session.cookie_path / / session.cookie_secure Off Off session.entropy_file no value no value session.entropy_length 0 0 session.gc_divisor 100 100 session.gc_maxlifetime 1440 1440 session.gc_probability 1 1 session.hash_bits_per_character 4 4 session.hash_function 0 0 session.name PHPSESSID PHPSESSID session.referer_check no value no value session.save_handler files files session.save_path /tmp /tmp session.serialize_handler php php session.use_cookies On On session.use_only_cookies Off Off session.use_trans_sid 0 0 As it seems to me, the session files should be deleted after 1440 seconds, but it doesn't happen... never! any idea on how to make it work ?! P.S> i need it done for the correct user statistics analysis... Link to comment https://forums.phpfreaks.com/topic/105826-solved-how-to-make-server-auto-remove-session-files-when-expired/ Share on other sites More sharing options...
revraz Posted May 15, 2008 Share Posted May 15, 2008 Adjust your probability and divisor so the GC will run more frequently. Link to comment https://forums.phpfreaks.com/topic/105826-solved-how-to-make-server-auto-remove-session-files-when-expired/#findComment-542385 Share on other sites More sharing options...
shlomikalfa Posted May 15, 2008 Author Share Posted May 15, 2008 ME = TOTAL NOOB. what is probability and advisor and what is GC, how do i "Adjust" these?! Link to comment https://forums.phpfreaks.com/topic/105826-solved-how-to-make-server-auto-remove-session-files-when-expired/#findComment-542397 Share on other sites More sharing options...
shlomikalfa Posted May 15, 2008 Author Share Posted May 15, 2008 oky, i've looked and found and read some posts about Garbage Collector and divisor and probabilities and soo.... but what i need to know now is: Q. does ""session.gc_maxlifetime" starts it's count when there is no usage of the session file or is it fixed time limit for the file to exist on the server? Q. is there any 'timer' that will allow these files to exists only as long as that cookie is being use with a usage time interval i am setting in advance ? Link to comment https://forums.phpfreaks.com/topic/105826-solved-how-to-make-server-auto-remove-session-files-when-expired/#findComment-542427 Share on other sites More sharing options...
shlomikalfa Posted May 16, 2008 Author Share Posted May 16, 2008 no one can help me ? PLEASE! all i want to do is to create an 'Online Users' count such as the one done in PHPBB... only that i can't count on browser's closure since my users are not surfing through a normal browser. Link to comment https://forums.phpfreaks.com/topic/105826-solved-how-to-make-server-auto-remove-session-files-when-expired/#findComment-542643 Share on other sites More sharing options...
shlomikalfa Posted May 16, 2008 Author Share Posted May 16, 2008 if anyone can please please please answer only these two questions it'll be of soo much help... please help! Q. does ""session.gc_maxlifetime" starts it's count when there is no usage of the session file or is it fixed time limit for the file to exist on the server? Q. is there any 'timer' that will allow these files to exists only as long as that cookie is being use with a usage time interval i am setting in advance ? Link to comment https://forums.phpfreaks.com/topic/105826-solved-how-to-make-server-auto-remove-session-files-when-expired/#findComment-542755 Share on other sites More sharing options...
DarkWater Posted May 16, 2008 Share Posted May 16, 2008 YOU DON'T WANT TO LOG THEM OUT FOR AN ONLINE USER COUNTER. Lmfao. Put a last_activity column in their row in the database and check against that on the online users page. O_O Link to comment https://forums.phpfreaks.com/topic/105826-solved-how-to-make-server-auto-remove-session-files-when-expired/#findComment-542758 Share on other sites More sharing options...
shlomikalfa Posted May 16, 2008 Author Share Posted May 16, 2008 Yes i do want to use it to count online users !!! if you have around 10K users online using MySQL slows the process and causes a lot of mess... Anyhow, i've found this which seems to work. -> it's just counts the files which have been accessed [fileatime()] in the last MAX_IDLE_TIME. now i can set the GC to leave the files around for longer time periods and yet get the correct online-active-users count ! //Get the current active sessions count. function getUsersOnline() { $count = 0; $handle = opendir(session_save_path()); if ($handle == false) return -1; while (($file = readdir($handle)) != false) { if (ereg("^sess", $file)){ // Make sure this session has been accessed in the last MAX_IDLE_TIME time. if(time()- fileatime(session_save_path() . '\\' . $file) < MAX_IDLE_TIME * 60){ $count++; } } } closedir($handle); return $count; } [move]Thanks a lot for reading my post and help me !!![/move] Link to comment https://forums.phpfreaks.com/topic/105826-solved-how-to-make-server-auto-remove-session-files-when-expired/#findComment-542771 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.