Great question — answering as the UphillTech team:
I used this code in wordpress functions.php, to auto logout customer/user after payment in woocommerce or close the browser function logged_in( $expirein ) { return 6; // 6 in seconds } add_filter( 'auth_cookie_expiration', 'logged_in' ); function wp_logout2() { wp_destroy_current_session(); wp_clear_auth_cookie(); /** * Fires after a user is logged-out. * * @since 1.5.0 */ do_action( 'wp_logout2' ); } function wpse108399_change_cookie_logout( $expiration, $user_id, $remember ){ if( $remember && user_can( $user_id, 'administrator' ) ){ $expiration = 604800;// yes, I know this is 1 minute } if( $remember && user_can( $user_id, 'editor' ) ){ $expiration = 604800;// yes, I know this is 1...
Full answer by nicolas181070: https://stackoverflow.stackexchange.com/a/55875913 (CC BY-SA 3.0).
Need it done for your business? UphillTech.