Javascript [removed] always empty string

前端 未结 5 1091
执念已碎
执念已碎 2020-11-30 01:53

I have this real strange problem with client side javascript setting cookies. I\'m developing a little 1 page demo at the moment to use cookies to store some \'preferences\'

5条回答
  •  天涯浪人
    2020-11-30 02:09

    HttpOnly cookies cannot be accessed from Javascript and session cookies are usually set as HttpOnly cookies. See also this StackOverflow question: How to read a secure cookie using JavaScript

    So... check whether the cookie you want to read has the 'HttpOnly' flag set... If so, you know the culprit. It's not a bug, it's a feature!

提交回复
热议问题