title: How to terminate duplicate user sessions with parse?
body: <p>I want my PFSessions to be exclusive, meaning, If a user is already logged in on a certain device in a certain location, if another device logs in with the same credentials, I want the previous session to be terminated, with a message of an alert view of course. Sort of like the old AOL Instant Messaging format. so does anyone know how I would go about doing so in swift? would it require CoreLocation?</p>
  
  <p>I found this article on current user location, how can I use this as part of a solution to my question ? </p>
  
  <p><a href="https://www.veasoftware.com/tutorials/2014/10/18/xcode-6-tutorial-ios-8-current-location-in-swift" rel="nofollow noreferrer">https://www.veasoftware.com/tutorials/2014/10/18/xcode-6-tutorial-ios-8-current-location-in-swift</a></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>so I've just read this parse article on their revocable sessions settings</p>
  
  <p><a href="http://blog.parse.com/announcements/announcing-new-enhanced-sessions/" rel="nofollow noreferrer">http://blog.parse.com/announcements/announcing-new-enhanced-sessions/</a></p>
  
  <p>however, when I log into the same account with a different device, the sessions are allowed to live correspondingly, which i do not want. How do I solve my dilemma?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I've gotten this very detailed description on how to achieve the overall method I'm trying to implement :</p>
  
  <p><a href="https://i.stack.imgur.com/khnqg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/khnqg.jpg" alt="enter image description here"></a></p>
  
  <p>however I am not very well versed in cloud code implementation, can someone very briefly portray a piece of code that is similar to what he's trying to relay onto me?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>So I did some more research and tied in what I was told in regards on how to use the cloud code calls in parse, and being I want to destroy previous sessions of the currentUser, I've written the following code in my login "success" logic:</p>
  
  <pre><code>            PFUser.logInWithUsernameInBackground(userName, password: passWord) {
          (user, error: NSError?) -&gt; Void in
          if user != nil || error == nil {
              dispatch_async(dispatch_get_main_queue()) {
                  self.performSegueWithIdentifier("loginSuccess", sender: self)
  
                   PFCloud.callFunctionInBackground("currentUser", withParameters: ["PFUser":"currentUser"])
                      //..... Get other currentUser session tokens and destroy them
  
              }
  
          } else {
  </code></pre>
  
  <p>If thats even the correct format or code, but I’m sure this is the right direction right? Can anybody edit or expand on the code I'm trying to achieve?</p>