Logout user
curl --request POST \
--url {protocol}://{host}/wp-json/cocart/v2/logoutimport requests
url = "{protocol}://{host}/wp-json/cocart/v2/logout"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('{protocol}://{host}/wp-json/cocart/v2/logout', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "{protocol}://{host}/wp-json/cocart/v2/logout",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{protocol}://{host}/wp-json/cocart/v2/logout"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("{protocol}://{host}/wp-json/cocart/v2/logout")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v2/logout")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodytrue{
"code": "cocart_logout_failed",
"message": "Logout failed.",
"data": {
"status": 400
}
}Logout User
Logs out the current user and destroys the session.
POST
/
logout
Logout user
curl --request POST \
--url {protocol}://{host}/wp-json/cocart/v2/logoutimport requests
url = "{protocol}://{host}/wp-json/cocart/v2/logout"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('{protocol}://{host}/wp-json/cocart/v2/logout', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "{protocol}://{host}/wp-json/cocart/v2/logout",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{protocol}://{host}/wp-json/cocart/v2/logout"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("{protocol}://{host}/wp-json/cocart/v2/logout")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v2/logout")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodytrue{
"code": "cocart_logout_failed",
"message": "Logout failed.",
"data": {
"status": 400
}
}Originally this endpoint was used to log out a user and their cart session when relying on WooCommerce session cookie. While the endpoint is not needed to clear the users session anymore, you can still use it to clear any WordPress cookies that may have been set.
Response
User logged out successfully.
The response is of type boolean.
Example:
true