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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With