Update and View Current Session Object in React

Hi All,

We have 2 questions about the session object.

We are using React Moralis. Using this library:

  1. How can we update the current session object for the user. Where when we add a new prop to the session it appears in the database dashboard under “_session” and persists if the user reloads the page.

In this doc it says " Session is a subclass of a Moralis Object , so you can query, update, and delete sessions in the same way that you manipulate normal objects on Moralis."
https://docs.moralis.io/moralis-dapp/users/sessions

But we cant seem to find the way to do this via the React Moralis. We see useNewMoralisObject and setUserData but cant seem to find a way to manage the session.

  1. Also, how can we get the current session object in React Moralis?

Thanks very much all

The session object only has an id, and expiration date and a pointer to a user.
The session id should be present in current user info.

If you want to modify some properties you can use a cloud function.

Tnx for your reply @cryptokid – so it IS possible to update live session via a could function? we will try this.

FYI - We need to do this so we can tie the auth provider to the session and recover the logged in session’s web3 provider (metamask vs other)…

You can update that session specific row from cloud code. Now I don’t know what you want to change or add there.