If I do:

global $wpdb;
$wpdb->query("DELETE FROM wp_options");

Suddenly, I'm logged out. But how come? I thought all sessions are kept locally, surely, a reference to my session must be present on the server, but how can I avoid this issue?

I want to wipe the entire table, just not these things related to the user sessions, as such, I identified certain possible keys that should be kept, but with no success:


What could be the issue here?

  • 2
    I recommend you to read this great article about wp_options table. kinsta.com/knowledgebase/wp-options-autoloaded-data/… – Jorge Casariego Aug 21 '18 at 3:18
  • Why would someone delete the complete wp_options table? – ahendwh2 Aug 21 '18 at 9:56
  • Dropping/clearing the wp-options table could break a lot of things. Plugins/themes store stuff in the wp-options table. As does WP, even on a newly created site.So you should be careful doing that. I'd even say that you shouldn't do that. Well-behaved plugins/theme will delete their items from the wp-options table when they are deleted. Although some will not, and it's not a big deal (IMHO) if they don't remove their stuff.The size of the wp-options table doesn't really affect the overall speed of the site, in most cases. – Rick Hellewell Aug 21 '18 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.