Coder Social home page Coder Social logo

connect session not working about union HOT 5 CLOSED

flatiron avatar flatiron commented on June 12, 2024
connect session not working

from union.

Comments (5)

PatrickHeneise avatar PatrickHeneise commented on June 12, 2024

I have the same problems and suspect passport.js is not working because of this either.

When making the change to connect, I get an error:

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot read property 'encrypted' of undefined
at ServerResponse. (/Users/pat/Sites/app/node_modules/connect/lib/middleware/session.js:226:31)

from union.

amelon avatar amelon commented on June 12, 2024

it's working now.
Thanks

from union.

xjamundx avatar xjamundx commented on June 12, 2024

Having similar problems using the following code which is straight from the connect docs.

var flatiron = require('flatiron')
var connect = require('connect')
var app = flatiron.app
app.use(flatiron.plugins.http);
app.http.before.push(connect.cookieParser('keyboard cat')); // secret here
app.http.before.push(connect.session({ cookie: { maxAge: 60000 }})); // no secret here
app.http.before.push(function(req, res) {
      var sess = req.session;
      if (sess.views) {
        res.setHeader('Content-Type', 'text/html');
        res.write('<p>views: ' + sess.views + '</p>');
        res.write('<p>expires in: ' + (sess.cookie.maxAge / 1000) + 's</p>');
        res.end();
        sess.views++;
      } else {
        sess.views = 1;
        res.end('welcome to the session demo. refresh!');
      }
})
app.start(4444)

You just always see "welcome to the session demo. refresh!" when using connect 2.3.3 and node 0.6.19.

In my case no cookies are being set. Anyone experienced this before?

from union.

amelon avatar amelon commented on June 12, 2024

I think cookies are set during res.setHeader.
You should set res.setHeader(...) before the "if"

from union.

xjamundx avatar xjamundx commented on June 12, 2024

The problem had to do with the version of something. I may have been on flatiron 0.2.1 or been using an older version of union. Wiping my package.json and node_modules and re-installing the latest of each requirement solved the problem.

from union.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.