Can't access cookies from [removed] in JS, but browser shows cookies exist

后端 未结 6 766
时光取名叫无心
时光取名叫无心 2020-11-28 04:38

I can\'t access any cookie from JavaScript. I need to read some value and send them via JSON for my custom checks.

I\'ve tried to access cookies from JS, like it was

6条回答
  •  遥遥无期
    2020-11-28 05:01

    If you are using some secure authentication then that case you could not access cookies directly because of secure. you have to change some response attribute in server side using below code .

    Response.AddHeader("Set-Cookie", "CookieName=CookieValue; path=/;");
    Response.SetCookie(new HttpCookie("session-id") { Value = Guid.NewGuid().ToString(), HttpOnly = false });
    Response.SetCookie(new HttpCookie("user-name") { Value = data.Login, HttpOnly = false });
    

    But you should not because it may change secure to un-secure, so you have to find out solution that be done in server side to delete cookies and allow to you do some operations.

    Its possible to do changes in server side.

提交回复
热议问题