Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

egg session 取值 undefined #3549

Closed
ChunrunHan opened this issue Mar 18, 2019 · 1 comment
Closed

egg session 取值 undefined #3549

ChunrunHan opened this issue Mar 18, 2019 · 1 comment

Comments

@ChunrunHan
Copy link

controller 里面存储
// 获取验证码
async getCaptcha(){
const {ctx} = this;
var captcha = ctx.service.user.getCaptcha();
ctx.session.code = captcha.text; // session 存储
console.log('session 存储',ctx.session.code)
ctx.body = captcha.data;
}

service里面打印ctx.session.code 为 undefined,为什么??????
// 检查验证码是否正确
checkCaptcha(code){
const {ctx} = this;
code = code.toLowerCase()
console.log("sessionCode",ctx.session.code) // undefined???????
let sessCode = ctx.session.code? ctx.session.code.toLowerCase():null
console.log("sesscode",sessCode)
//验证
if(code === sessCode){
// 成功之后验证码作废
ctx.session.code = null
}
return code === sessCode;
}

@egg-bot
Copy link

egg-bot commented Mar 18, 2019

Hello @ChunrunHan. Please provide a reproducible example following the instruction.

Issues labeled by Need Reproduce will be closed if no activities in 7 days.


@ChunrunHan,请根据这个说明提供最小可复现代码。

如果在 7 天内没有进展会被自动关闭。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants