Logout customer
curl --request POST \
--url {protocol}://{host}/wp-json/cocart/v1/logoutimport requests
url = "{protocol}://{host}/wp-json/cocart/v1/logout"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('{protocol}://{host}/wp-json/cocart/v1/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/v1/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/v1/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/v1/logout")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v1/logout")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodytrueLogout
Logs out the customer and clears their session.
POST
/
logout
Logout customer
curl --request POST \
--url {protocol}://{host}/wp-json/cocart/v1/logoutimport requests
url = "{protocol}://{host}/wp-json/cocart/v1/logout"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('{protocol}://{host}/wp-json/cocart/v1/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/v1/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/v1/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/v1/logout")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/v1/logout")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodytrueOriginally 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
200 - application/json
Customer logged out successfully.
The response is of type boolean.
Example:
true