eggjs / egg

🥚 Born to build better enterprise frameworks and apps with Node.js & Koa
https://eggjs.org
MIT License
18.89k stars 1.82k forks source link

sessionid获取不到 #3248

Closed Vcgoyo closed 5 years ago

Vcgoyo commented 5 years ago

使用egg-redis,egg-session-redis 将session存储在redis中,目前场景需要获取sessionid ,如果将session的encrypt设置为false后getcookie才能拿到sessionid,encrypt设置为true后getcookie就拿不到了,请问这个有解决方案吗~

atian25 commented 5 years ago

前端读取 cookie ?

Vcgoyo commented 5 years ago

@atian25 不是 在node端 使用ctx.cookies.get(sessionKey) 获取sessionid

atian25 commented 5 years ago

ctx.cookies.get(sessionKey, { encrypt: true })

Vcgoyo commented 5 years ago

谢谢 提供session过期事件监听吗 我看 app.on('session:expired') 这些好像没有效果

Vcgoyo commented 5 years ago

@atian25

atian25 commented 5 years ago

https://github.com/koajs/session 这里的文档是支持的。你可以研究下它的 test fixture