Skip to content

Commit

Permalink
Merge pull request #73 from ceramicnetwork/oed-patch-1
Browse files Browse the repository at this point in the history
docs: add docs for removing a session
  • Loading branch information
JustinaPetr authored Feb 26, 2024
2 parents 76b1a16 + a415be4 commit 87b475b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions docs/dids/managing-sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ if (await DIDSession.hasSessionFor(accountId, resources: [...])) {
}
```

### Removing a persisted session

## Session lifecycle management
If you want to remove a persisted session that was created using `DIDSession.get(...)`, you can use the static function `remove`. This will permanently remove the persisted session for a given account, and the user would need to reauthenticate in order to establish a new session.

```js
await DIDSession.remove(accountId)
```

Additional helper functions are available on DIDSession instances to help you manage a session lifecycle and the user experience.

### Session lifecycle management

Additional helper fields are available on DIDSession instances. They can help you manage a session lifecycle and the user experience. For example, if a session has expired you might want to show a message to the user before you ask them for a new session.

```js
// Check if authorized or created from existing session string
Expand Down Expand Up @@ -49,4 +57,4 @@ const sessionString = session.serialize()

// Later re initialize session
const session2 = await DIDSession.fromSession(sessionString)
```
```

0 comments on commit 87b475b

Please sign in to comment.