Angular is not sending the Cookie received in Set-Cookie even if withCredentials is true

前端 未结 3 2251
南笙
南笙 2020-12-13 09:07

For cookie based authentication, my server sends Set-Cookie to my Angular application. However, the application doesn\'t send the value back in further requests

3条回答
  •  没有蜡笔的小新
    2020-12-13 09:52

    i assume you using nodejs and express-session for manage session then in express-session httpOnly are by default enabled so you have to change httpOnly for console sever sent cookie

    const app = require('express')();
    var session = require('express-session');
    var cookieParser = require('cookie-parser');

    app.use(session( { secret:'hello world',
    store:SessionStore,
    resave:false,
    cookie:{
    secure:false,
    httpOnly:false // by default it's boolean value true }
    }));

    in the below image httpOnly are true, so you can't be console this cookie.

    in the below image httpOnly are false , so you can console this cookie.

提交回复
热议问题