admin管理员组

文章数量:1401208

I want to use localStorage on the client side and right now I am sending that data in the body of an AJAX request. However, it would be nice to be able to send the data with the page request. Is there a way to place localStorage data (or I guess any data) in the HTTP header such that I can read it with Javascript and store it in localstorage?

I want to use localStorage on the client side and right now I am sending that data in the body of an AJAX request. However, it would be nice to be able to send the data with the page request. Is there a way to place localStorage data (or I guess any data) in the HTTP header such that I can read it with Javascript and store it in localstorage?

Share Improve this question asked Sep 26, 2014 at 17:44 Justin ElkowJustin Elkow 2,9438 gold badges32 silver badges62 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

There is no automatic way to put something in local storage by passing an HTTP header.

Your idea of reading the header with JavaScript won't work either, assuming you're referring to the page that the JavaScript is running on. The JavaScript has no way to get the response headers directly.

You could always load your data via AJAX or similar.

only with cookie like schoolbus from localstorage to server and back

本文标签: javascriptCan localstorage data be placed in the HTTP headerStack Overflow