search

Home  >  Q&A  >  body text

node.js - Unable to obtain session in express router

I use app.post(); directly in app.js to get the session.
But I can’t get the session when I use router.post(); in the router.
What’s going on? Seek the guidance of the great God

As shown

Display seesion cannot be obtained

ringa_leeringa_lee2832 days ago869

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-05-17 09:59:04

    Is it a matter of order? The session middleware needs to be before all routers

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-17 09:59:04

    It seems that your second router is not associated with the app,
    so the one behind you does not enter the session middleware, causing the session to be unavailable.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-17 09:59:04

    app.use('/xxx', router);

    Is this missing?

    reply
    0
  • Cancelreply