Finding an answer from the wp sessions author
http://wordpress.org/support/topic/garbage-collection-not-working
PS the next version is being returned to PHP sessions
Mike, which version of the WP_Session object did you wrap in to the plugin?
Looking into the code, a couple of things are happening.
First, the garbage collection routine is registered on the wp
hook, which isn’t run on the back end unless you’re doing a query. So refreshing the dashboard won’t do anything.
Second, the wp_session_garbage_collection
hook is scheduled to run twice daily. So while sessions are only valid for a certain period of time (~30 mins, unless you configure it otherwise) they stay in the database until the garbage collector runs.
You can verify that the scheduled event is in the Cron in a debug environment by:
- Setting
WP_DEBUG
to true
- Installing the Debug Bar plugin
- Installing Debug Bar Cron
You should see the wp_session_garbage_collection
event in the custom events section as in this screenshot: http://d.pr/i/YPLQ
Hi Mike
I am also finding tonnes of _wp_session entries in the DB – the DB is getting very bloated. Is there any way to solve this as a fix?
Thanks
Thread Starter
Qcybb
(@qcybb)
Thanks Mike, reverting back to PHP sessions would be great.
Any rough ETA when this will happen?
Maybe a week
Just have to find the time
Eric,
I still do not think the garbage collection works at all, you might want to check your code again.
I have 3800 rows of
_wp_session_[session_id]
0 rows of
_wp_session_expires_[session_id]
The wp_session_cleanup function does nothing because of this.
I suspect this is why I have been getting support posts like this
http://wordpress.org/support/topic/vcita-wp_sessions-being-added-to-wp_options-table
One user found 260,487 sessions in there
Update to Version: 3.1.8.2 or higher to fix this.
The database will be cleaned up also
I switched back to PHP sessions because WP Sessions had issues with cache plugins.
Just wanted to follow up on this.
It turns out the portion of code that was registering the timeout window for sessions was lost in version 1.1, so newly created sessions were being created without any sort of timestamp (meaning the garbage collector didn’t know what to clean up). This is likely the result of too many people trying to refactor at once, and my inability to keep track of who was removing which function.
In any case, the bug has been resolved for version 1.1.1 => http://wordpress.org/plugins/wp-session-manager/