# OpenVidu Session Persistance

**URL:** <https://openvidu.discourse.group/t/openvidu-session-persistance/2004>\
**Category:** How to implement?\
**Tags:** v2\
**Created:** [September 11, 2020, 3:42pm UTC](https://openvidu.discourse.group/t/openvidu-session-persistance/2004 "2020-09-11T15:42:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bettyboop](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/bettyboop/32/964_2.png) [@bettyboop](https://openvidu.discourse.group/u/bettyboop)\
**Post date:** [September 11, 2020, 3:42pm UTC](https://openvidu.discourse.group/t/openvidu-session-persistance/2004/1 "2020-09-11T15:42:04Z")

</div>

Will a session created on openvidu stay open permanently so long as .close() is not called on it?

For example:

A user creates a Meeting in my webapp

- I create my Meeting object and at that time I ping my openvidu instance to create a session with a custom session\_id.
- I store session\_id on my meeting object, and use it for creating tokens and other purposes.

Even if a long time passes, I do not need to worry about losing the session object on my openvidu server until I explicitely call session.close() on the matching Meeting’s session\_id?

---

<div class="post-metadata">

**Author:** ![pabloFuente](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/pablofuente/32/2536_2.png) [@pabloFuente](https://openvidu.discourse.group/u/pabloFuente)\
**Post date:** [September 11, 2020, 10:09pm UTC](https://openvidu.discourse.group/t/openvidu-session-persistance/2004/2 "2020-09-11T22:09:16Z")

</div>

The session will be automatically closed when the last participant disconnects, bare that in mind. If you want to overcome this, you must manage the possibility of having to re-create again your “customSessionId” session. Will be a different one, but just with the same identifier.

---

<div class="post-metadata">

**Author:** ![bettyboop](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/bettyboop/32/964_2.png) [@bettyboop](https://openvidu.discourse.group/u/bettyboop)\
**Post date:** [September 12, 2020, 1:07am UTC](https://openvidu.discourse.group/t/openvidu-session-persistance/2004/3 "2020-09-12T01:07:26Z")

</div>

Thanks for the clarification, Pablo. If I am creating the session programmatically like this, I will not have added any participants yet.

Does this mean that so long as no participants are added, the session will remain open indefinitely. But once one is added and then removed by any means, it will close?

---

<div class="post-metadata">

**Author:** ![bettyboop](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/bettyboop/32/964_2.png) [@bettyboop](https://openvidu.discourse.group/u/bettyboop)\
**Post date:** [September 12, 2020, 4:52pm UTC](https://openvidu.discourse.group/t/openvidu-session-persistance/2004/4 "2020-09-12T16:52:07Z")

</div>

I see now there is information on the session lifecycle in this thread:

> [@Session Lifecycle](https://openvidu.discourse.group/t/session-lifecycle/103):
>
> What is the life cycle of a session? Openvidu deletes sessions if there is no transmission? Openvidu eliminates transmissions at some point?

Added [an issue](https://github.com/OpenVidu/openvidu.io-docs/issues/38) to enhance docs on this.
