Back

SESSION LENGTH EXPIRATION

  • 0
  • Users
  • Accounts
Samuel Kings
21 Jul, 2023, 17:37

In the console where we can determine the session length... I want to ask (let's assume I set it to 7 days) if this means that the session will expire 7 days after creation or after user inactivity. Thanks

TL;DR
The user is asking if the `createdAt` attribute can be queried with greater than and less than queries. They also want to know how to detect users who have not been active for the past 30 days. A suggested solution is to create a collection and update it with a function that runs when the user enters the app or directly from the client SDK. Then, query that collection to check for rows after a certain date. To prevent the collection from becoming too large, make the `user_id` unique and only enter once, then update the last seen. This collection will help determine if a session is expired or not.
Binyamin
21 Jul, 2023, 17:43

In total

Binyamin
21 Jul, 2023, 17:43
Samuel Kings
21 Jul, 2023, 17:51

I see. How then do you suggest I detect users who have not been online or active for (let's say) the past 30 days?

Samuel Kings
21 Jul, 2023, 17:53

Another question is: Will the "current" property of the session object be changed to false after session has expired?

Binyamin
21 Jul, 2023, 17:54

What you mean by change to false?

Samuel Kings
21 Jul, 2023, 17:54

This.

Binyamin
21 Jul, 2023, 17:55

This means if you ask for all sessions, like for a few devices then to the current one will be true If the session is expired then no session will return whatsoever

Samuel Kings
21 Jul, 2023, 17:56

I see. That helps

Binyamin
21 Jul, 2023, 17:57

That's a good question. A best solution would be Appwrite adds it to the account.get() endpoint and part of the user model.

For now, you'll have to create some collection and let it update by:

  • Function that will update as the user entering the App
  • Directly from the client SDK.

Then you can query that collection by checking only rows that after X date.

To make sure this collection won't get bigger and bigger you can make the user_id unqiue, then only enter once and then update the user last seen.

Samuel Kings
21 Jul, 2023, 17:58

Perfect. Makes perfect sense

Samuel Kings
21 Jul, 2023, 17:58

Last question...

Samuel Kings
21 Jul, 2023, 18:00

Can the $createdAt attribute be queried with the greater than and less than queries? Cos I was having a feeling they may only work on integer attributes

Binyamin
21 Jul, 2023, 18:00

Yes it could

Binyamin
21 Jul, 2023, 18:01

You'll need to send a ISO date to the query

Samuel Kings
21 Jul, 2023, 18:02

Alright. Thank you very much

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more