How to keep the Session Logged In

Hi,

My application uses Inrupt’s JavaScript Libraries and I am using normal HTML/CSS. I have multiple pages like ‘add-devices’ and ‘read-devices’ and I want to keep the session logged in when I move from one page to another.
I have looked at the documentation on Session Restore (that can be found here). But I am encountering some issues.

When I use handleIncomingRedirect({ restorePreviousSession : true }); ; the page performs a silent authentication but it takes me back to ‘add-devices’ page every time. So, I cannot go to another page like ‘read-devices’ since I am redirected to ‘add-devices’ every time.

When I use handleIncomingRedirect(); ; I am taken to Inrupt’s webpage to grant access to the app every time I change pages.

I tried to use onSessionRestore() but it gave me errors. I think I am using it wrong - I don’t know where to place it correctly and how should I give the URL to the page that I want to go to after silent authentication.

Any tips on how I can solve this?

Thank you very much in advance!

Hey Tanmay

I think you’re already close to the solution. For a project we’ve first added a listener to onSessionRestore. When it is called, it will take the url where the login process was started and then you can manually go to this URL with your framework (assuming you have a single-page-application, eg with React or Angular). Then we call handleIncomingRedirect({ restorePreviousSession : true }); which will trigger the silent authentication and call onSessionRestore when it’s finished.

For reference, here is our corresponding code: solidcryptpad/simple-solid-authentication.service.ts at 74f93fee06fcb93b454f6004863647ef11e9c24f · solidcryptpad/solidcryptpad · GitHub

In case you don’t have a single-page-application, I am not sure if or how this can be done. My guess it that at least currently it’s not possible with this library.