• Resolved botoxparty

    (@adamhammad)


    I’d like to propose a logout endpoint that calls wp_logout() to remove any cookies.

    I’m using something basic like..

    add_action( 'rest_api_init', function () {
            register_rest_route( 'custom', 'v1/logout', array(
            'methods' => 'GET',
            'callback' => 'custom_logout',
        ) );
    } );
    
    function custom_logout() {
        return wp_logout();
    }

    Not sure if i’m missing or anything but yeah not calling wp_logout() was causing a lot of problems for my frontend.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Ali Qureshi

    (@parorrey)

    Hello,

    When you use generate_auth_cookie, you have the option to create the cookie value for a specific time period. please note, though it is cookie value, but no cookie is created or written in browser as you are using REST API. there is no cookie to unset in the first place in your mobile app.

    It will only work if you are using browser and using REST API to login web app. FOr mobile app, forget cookie value is better option.

    Thank you for posting the solution that may work for eb apps.

    Thread Starter botoxparty

    (@adamhammad)

    Ahh okay. There are cookies that are being set in my app. My app uses WooCommerce and they are coming from there to track cart sessions.

    So yeah anyone out there who is having problems with WooCommerce sessions, make sure you unset your cookies when you get rid of your token, or call wp_logout().

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Logout endpoint’ is closed to new replies.