Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a cookies based session store for nodejs (connect, express)?

in rails the default session store uses cookies. the session is marshaled and signed with a secret key so that client can't temper with it. this approach is very scalable and doesn't require any kind of 'backend' to work.

I can't find anything like that for Express or Connect.

like image 714
Vitaly Kushner Avatar asked Jan 22 '12 05:01

Vitaly Kushner


People also ask

Does Express-session use cookies?

Here is a simple explanation: - A user session can be stored in two main ways with cookies: on the server or on the client. express-session stores only a session identifier on the client within a cookie and stores the session data on the server, typically in a database.

How do you set an express-session cookie?

var cookieSession = require('cookie-session') var express = require('express') var app = express() app. use(cookieSession({ name: 'session', keys: ['key1', 'key2'] })) // Update a value in the cookie so that the set-cookie will be sent. // Only changes every minute so that it's not sent with every request. app.

What is session cookie in Nodejs?

Session cookies: Session cookies are the temporary cookies that mainly generated on the server-side. The main use of these cookies to track all the request information that has been made by the client overall particular session.


1 Answers

Connect 2x has one built-in and this is an example of how simple it would be to get something basic going with Express 3x https://gist.github.com/1491756 with the new signed cookie support. You can still do the same thing without upgrading but you'll need to use utils instead of those getters

like image 63
TJ Holowaychuk Avatar answered Sep 28 '22 02:09

TJ Holowaychuk