Posted in

How to force logout all users from WordPress (no plugin)

Binary reflections wordpress force logout all users

If you are a WordPress administrator then occasionally you might want to force logout all users at once without asking them to manually logout. In fact, it’s a good security practice to periodically do this to make sure that there are no perpetual login sessions. Here’s how to do it.

Step 1: Login to your server and go the WordPress root directory

Step 2: Open the wp-config.php file and look for a code block that looks like this:

define('AUTH_KEY',         'rh g-x+@l:6gpCOjO)s2L(1uB=Op*6$]E}uK5;laEMmo#c%-/[zUrb+eu1Xpl]6&');
define('SECURE_AUTH_KEY',  'j?#nlmj(R p}B(9r|tN$gqTRw%{XR+ixRxHozKxo $?r@Uo+MNdri,]J@.{d-Bu|');
define('LOGGED_IN_KEY',    'xEDHDW/t,2Z8T<N0#s)+S4p=.fR0=;89$~F@:YrFZQ5.=>$IM_8V)`%`ontwaxB]');
define('NONCE_KEY',        '|y-2+LOszpUks?)|KjV=]$#89u!/a3wlj30X&cxD>5EK^qx].D[x=3-(cB!.cY)z');
define('AUTH_SALT',        'vhCm9)_5i;,sawsGGbA8CefceDB$H-W|Zw@fJPMpey:BjnSxsX9^52R0wG7:e>S~');
define('SECURE_AUTH_SALT', 'lYZHGOqOU)J]1/w&BA]aCN e)-^}Z5m,p5CS]d!rN|YaookF6_~+{_=X!FB#q03}');
define('LOGGED_IN_SALT',   '++3Gs/Mc-*LI~4+UEk]2AsOGv0Z7K=nm8VcZT&z^#:p_S19JfMOtA=N2$/t2 y?K');
define('NONCE_SALT',       '+$op5|=<M+0HVq|]I-!?8IBe|WMmotSwM=yz(#nD(u3>+gn-2^=&+MbYqY)+!5_i');
PHP

Step 3: Go to the WordPress secret key generator in your browser and copy the entire code block generated on that page.

Step 4: Replace the code block in wp-config.php file with the new one generated in step 3 and save the file.

That’s it! All logged in sessions will be terminated and all users will be forcefully logged out.