# Destroying a users session via api

**URL:** <https://meta.discourse.org/t/destroying-a-users-session-via-api/49794>\
**Category:** Development\
**Tags:** rest-api\
**Created:** [6 Settembre 2016, 10:15pm UTC](https://meta.discourse.org/t/destroying-a-users-session-via-api/49794 "2016-09-06T22:15:01Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![mb450](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mb450/32/121465_2.png) [@mb450](https://meta.discourse.org/u/mb450)\
**Post date:** [6 Settembre 2016, 10:15pm UTC](https://meta.discourse.org/t/destroying-a-users-session-via-api/49794/1 "2016-09-06T22:15:01Z")

</div>

Hi,

I need to destory a session for a given user. (Using sso at the moment) but my users can logout of my main website but I want them to be able logged out of the forum at the same time.

Here’s what I’ve tried (cut down test)

```
   $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, 'https://forum.blah.com/session/admin1?api_key=<blah blah blah>=&api_username=system');
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($ch, CURLOPT_HEADER, 1);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
            $response = curl_exec($ch);
            var_dump($response);

```

I get a 302 redirect ever time.

But if I do a delete from postman with the same url it works perfectly…

What am I missing?!

---

_[View the full topic](https://meta.discourse.org/t/destroying-a-users-session-via-api/49794)._
