How to "subscribe" to deletion of sessions

Hello, I am building a client that logs into parse and stores a session token upon login. I would like to ‘subscribe’ to the deletion of that token so when it expires and parse deletes it, the client side tells the user that they have to log back in. Currently, I have a thread running a check on the token every 2 minutes to see if it is still valid. While digging through parse documentation, I found that parse supports webhooks. From my understanding of them, you make a rest API call and when the trigger for the hook is tripped, the API call returns. Is that a correct interpretation and could I use a webhook to track the expiration of a token or do I need to find another way? If this is the correct tool to solve my issue, how would I go about doing this?

I don’t think web hooks will help you in this case as they are useful for integrating two different applications and not client/server integration. Live Query can help you on your challenge, but I am afraid it currently does not support triggers on Session class.

1 Like

You can used LiveQuery on Parse.Session since version 5 :blush:


The client that I am making is written in c#, I don’t see a way to use a live query in c#/unity though. I was thinking that maybe I have a custom function in the cloud code that when given session id, it just asynchronously waits till the live query comes back saying the key was deleted and then returns that back to the caller. Would that workaround work for what I am trying to do?

I don’t think so. Cloud code function will timeout. For C#, have you tried this one?

If you prefer, you can always open the web socket connection directly to the server and talk the protocol: Parse LiveQuery Protocol Specification · parse-community/parse-server Wiki · GitHub