How to make Angular application read cookies at start up

前端 未结 1 1662
生来不讨喜
生来不讨喜 2021-01-29 00:54

I have an Angular application which on start up should read Cookies (app.component.ts) and should redirect to a new component passing the

相关标签:
1条回答
  • 2021-01-29 01:13

    I'll be happy to accept other answers but the research so far hints that what I am trying to do can't be done. Quoting a response from (Accessing the web page's HTTP Headers in JavaScript), Unfortunately, there isn't an API to give you the HTTP response headers for your initial page request.. So what I am doing at the moment is probably one of the possible work arounds 1) I can set html attributes. If I am concerned about security, I can make them hidden - https://www.w3schools.com/tags/att_global_hidden.asp 2) I can set cookies in the response and get the cookies using plain javascript (document.cookies). https://www.w3schools.com/js/js_cookies.asp and What is the equivalent to AngularJS's ngcookie in Angular 6?

    0 讨论(0)
提交回复
热议问题