# How to keep the Session Logged In

**URL:** <https://forum.solidproject.org/t/how-to-keep-the-session-logged-in/6240>\
**Category:** Build a Solid App\
**Created:** [March 3, 2023, 4:21pm UTC](https://forum.solidproject.org/t/how-to-keep-the-session-logged-in/6240 "2023-03-03T16:21:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanmay](https://avatars.discourse-cdn.com/v4/letter/t/ccd318/32.png) [@tanmay](https://forum.solidproject.org/u/tanmay)\
**Post date:** [March 3, 2023, 4:21pm UTC](https://forum.solidproject.org/t/how-to-keep-the-session-logged-in/6240/1 "2023-03-03T16:21:21Z")

</div>

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](https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/restore-session-browser-refresh/)). 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!

---

<div class="post-metadata">

**Author:** ![A\_A](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/a_a/32/786_2.png) [@A\_A](https://forum.solidproject.org/u/A_A)\
**Post date:** [March 6, 2023, 8:27pm UTC](https://forum.solidproject.org/t/how-to-keep-the-session-logged-in/6240/2 "2023-03-06T20:27:12Z")

</div>

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](https://github.com/solidcryptpad/solidcryptpad/blob/74f93fee06fcb93b454f6004863647ef11e9c24f/src/app/services/authentication/simple-solid-authentication.service.ts#L37-L49)

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.
