https://github.com/donavon/multi-cookie-session
https://github.com/donavon/multi-cookie-session
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/donavon/multi-cookie-session
- Owner: donavon
- License: mit
- Created: 2021-01-30T00:16:34.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-01-19T18:33:41.000Z (over 1 year ago)
- Last Synced: 2025-01-07T17:16:31.795Z (9 months ago)
- Language: TypeScript
- Size: 289 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Multi-Cookie Session
A cookie-based session middleware for Express.
- Doesn't have a 4KB size limit.
- Can optionally send encrypted cookies.
- Completely written in TypeScript.## Why?
Many people use [cookie-session](https://github.com/expressjs/cookie-session) middleware for Express for a simple cookie-based session solution. However, the size of an individual cookie is limited to 4KB in most browsers. If you need larger sessions, you either stand up a backend session data store using [express-session](https://github.com/expressjs/session) — which can be difficult and costly — or you're out of luck. Until now.
`multi-cookie-session` started off as a fork of the `cookie-session`. It has been changed to allow session data to be spread across many cookies, thus eliminating the 4KB per cookie rule.
## Install
```bash
$ npm i multi-cookie-session
```or
```bash
$ yarn multi-cookie-session
```## Use
```js
import { multiCookieSession } from 'multi-cookie-session';const sessionConfig = {
// Options
};export const session = app => {
app.use(multiCookieSession(sessionConfig));
};
```## API
`multi-cookie-session` is API compatable with `cookie-session` so it's easy and familiar. For a full list, see [cookies session documentation](https://github.com/expressjs/cookie-session/blob/master/README.md).
## TypeScript
You can fully type your session variables. See the following for an example:
```ts
type MySession = {
foo: string;
bar: Bar;
baz: number;
};// Extend the session data type
declare module 'multi-cookie-session' {
interface SessionData extends MySession {}
}
```