Skip to content
Myr

Added session usage docs. Closes #443

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent fab9af2 · Browse files · 1 file+18 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+18 added−5 removed

  • other:+18 added−5 removed

1 file+18 added−5 removed

modified:docs/guide.md+18 added-5 removed
212 unmodified lines
213 });214215### Middleware216217The Express _Plugin_ is no more! middleware via [Connect](http://github.com/senchalabs/connect) can be217Middleware via [Connect](http://github.com/senchalabs/connect) can be218passed to _express.createServer()_ as you would with a regular Connect server. For example:219220 var express = require('express');220 var express = require('express');221222 var app = express.createServer(223 express.logger(),224 express.bodyDecoder()225 );223 express.logger(),224 express.bodyDecoder()225 );226227Alternatively we can _use()_ them which is useful when adding middleware within _configure()_ blocks:228229 app.use(express.logger({ format: ':method :uri' }));
167 unmodified lines
397 * [Jade](http://jade-lang.com) haml.js successor398 * [Haml](http://github.com/visionmedia/haml.js) pythonic indented templates399 * [EJS](http://github.com/visionmedia/ejs) Embedded JavaScript400401### Session Support402403Sessions support can be added by using Connect's _session_ middleware. To do so we also need the _cookieDecoder_ middleware place above it, which will parse and populate cookie data to _req.cookies_.404405 app.use(express.cookieDecoder());406 app.use(express.session());407408By default the _session_ middleware uses the memory store bundled with Connect, however many implementations exist. For example [connect-redis](http://github.com/visionmedia/connect-redis) supplies a [Redis](http://code.google.com/p/redis/) session store and can be used as shown below:409410 var RedisStore = require('connect-redis');411 app.use(express.cookieDecoder());412 app.use(express.session({ store: new RedisStore }));413414### req.header(key[, defaultValue])415416Get the case-insensitive request header _key_, with optional _defaultValue_:417
398 unmodified lines