Skip to content

Instantly share code, notes, and snippets.

@nathanielks
Created September 29, 2016 17:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanielks/1997f3694d1c644c46021c515b764151 to your computer and use it in GitHub Desktop.
Save nathanielks/1997f3694d1c644c46021c515b764151 to your computer and use it in GitHub Desktop.
SQL query to delete expired WooCommerce Sessions.
delete from t1, t2
using wp_options t1
join wp_options t2 on t2.option_name = replace(t1.option_name, '_expires', '')
where (t1.option_name like '\_wc\_session\_expires\_%')
and t1.option_value < UNIX_TIMESTAMP(NOW())
@nathanielks
Copy link
Author

Be sure to update wp_ to whatever the prefix is for your database. This deletes all expired sessions in your options table. Doesn't touch the wc_sessions table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment