# session-data

> Store Data into session middleware for Connect.

Latest version **1.1.2** (published 2015-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install session-data
pnpm add session-data
yarn add session-data
bun add session-data
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2015-06-12 |
| First published | 2015-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nicolas Rollin |
| Maintainers | asw20 |
| Keywords | connect, express, session, data |

## Links

- npm: https://www.npmjs.com/package/session-data
- Repository: https://github.com/Asw20/session-data
- Issues: http://github.com/Asw20/session-data/issues
- npm.io page: https://npm.io/package/session-data

## Dependencies (1)

- [util](https://npm.io/package/util.md) 0.10.x

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2015-06-12
- 1.1.1 — 2015-06-12
- 0.1.1 — 2015-05-28

## README

# session-data

The sessionData is a special area of the session used for storing data.  Data
are written to the sessionData and cleared after being used by the user.  The
sessionData is typically used in combination with redirects, ensuring that the data
is available to the next page that is to be rendered.

## Install

    $ npm install session-data

## Usage

#### Express 3.x

sessionData are stored in the session.  First, setup sessions as usual by
enabling `cookieParser` and `session` middleware.  Then, use `sessionData` middleware
provided by session-data.

```javascript
var sessionData = require('session-data');
var app = express();

app.configure(function() {
  app.use(express.cookieParser('keyboard cat'));
  app.use(express.session({ cookie: { maxAge: 60000 }}));
  app.use(sessionData());
});
```

With the `sessionData` middleware in place, all requests will have a `req.sessionData()` function
that can be used for sessionData.

```javascript
app.get('/sessionData', function(req, res){
  // Set a flash message by passing the key, followed by the value, to req.sessionData().
  req.sessionData('info', 'Flash is back!')
  res.redirect('/');
});

app.get('/', function(req, res){
  // Get an array of sessionData by passing the key to req.sessionData()
  res.render('index', { sessionData: req.sessionData('info') });
});
```

## Examples

https://github.com/Asw20/Jdemo/tree/master/demo_sessiondata

## Tests

    $ npm install --dev
    $ make test

[![Build Status](https://secure.travis-ci.org/Asw20/session-data.png)](http://travis-ci.org/Asw20/session-data)

## Credits

  - [Nicolas Rollin](http://github.com/Asw20)
  - [Jared Hanson](http://github.com/jaredhanson)


## License

[The MIT License](http://opensource.org/licenses/MIT)

Copyright (c) 2012-2015 Nicolas Rollin <[http://objclt.com/](http://objclt.com/)>

---
_Source: https://npm.io/package/session-data · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
