# iOS Swift SDK clearSession() not working as intended

**URL:** <https://community.auth0.com/t/ios-swift-sdk-clearsession-not-working-as-intended/8452>\
**Category:** Get Help\
**Tags:** ios\
**Created:** [October 11, 2017, 6:20pm UTC](https://community.auth0.com/t/ios-swift-sdk-clearsession-not-working-as-intended/8452 "2017-10-11T18:20:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiahekuang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jiahekuang/32/7351_2.png) [@jiahekuang](https://community.auth0.com/u/jiahekuang)\
**Post date:** [October 11, 2017, 6:20pm UTC](https://community.auth0.com/t/ios-swift-sdk-clearsession-not-working-as-intended/8452/1 "2017-10-11T18:20:33Z")

</div>

**Language** : Swift4

**Login Implementation:** Using Auth0 Swift SDK.

**Test Platforms** : iOS11 simulator, iPhone6 Plus running iOS10

**Integrated Social Platforms** : Google, Microsoft Live

**Intention** : Want to log the user out on the application level and clear SSO session after the user pressed the log out button, so the next time they want to log in, they would have to enter in their social credentials in a SafariViewController.

**Current Implementation:**

```
Auth0.webAuth().clearSession(federated: false) { (isLoggedOut) in
        if isLoggedOut{
            DispatchQueue.main.async {
                let keychain = A0SimpleKeychain(service: "Auth0")
                keychain.clearAll()
               //Perform UI Updates
                })
            }
        }
    }

```

**Current Behavior(Not what I am expecting)**: When tapping on the login with Google button on the login page, it doesn’t ask for credentials, and logs in the user directly. (Which would be the intended and expected behavior if I didn’t clear the SSO session.)

**Question** : Is the clearSession() API under the WebAuth protocol working as intended? or Am I misusing it?

---

<div class="post-metadata">

**Author:** ![withp17](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@withp17](https://community.auth0.com/u/withp17)\
**Post date:** [October 19, 2017, 1:17am UTC](https://community.auth0.com/t/ios-swift-sdk-clearsession-not-working-as-intended/8452/2 "2017-10-19T01:17:50Z")

</div>

Hi ,  
I am also facing the same issue with Auth0 cleatAll()  
Please let me know if anybody knew the solution.

Thanks,  
Venkat

---

<div class="post-metadata">

**Author:** ![jiahekuang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jiahekuang/32/7351_2.png) [@jiahekuang](https://community.auth0.com/u/jiahekuang)\
**Post date:** [October 21, 2017, 7:51am UTC](https://community.auth0.com/t/ios-swift-sdk-clearsession-not-working-as-intended/8452/3 "2017-10-21T07:51:18Z")

</div>

Hello there,  
I actually checked into their Github branch for the Swift SDK. It seems like there are failed tests with the clearSession() API. I think they are working on a new implementation using the new SafariAuthtenticationVC. I suggest following their GitHub Swift branch for the latest updates.

---

<div class="post-metadata">

**Author:** ![sohayb.hassoun](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sohayb.hassoun](https://community.auth0.com/u/sohayb.hassoun)\
**Post date:** [December 17, 2017, 10:17am UTC](https://community.auth0.com/t/ios-swift-sdk-clearsession-not-working-as-intended/8452/4 "2017-12-17T10:17:58Z")

</div>

It is kind of weird that they haven’t addressed this issue yet ☹

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/ios-swift-sdk-clearsession-not-working-as-intended/8452/5 "2018-03-02T05:56:55Z")

</div>


