Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get the HTML5 Local storage values in server side

I am a .Net developer, I know that the HTM5 localstorage is client-side storage technique. I want to get the local storage data on the server-side.

For getting cookie value from server-side we have Request.Cookie in ASP.NET. Is there any solution like that to take the local storage value directly on the server-side? Please guide me. I am using the .net 4.0 framework

Thanks, Jibu

like image 258
Jibu P C_Adoor Avatar asked Nov 15 '11 10:11

Jibu P C_Adoor


2 Answers

You will need to pass this information from the client to the server using standard HTTP techniques. Using javascript you could fill:

  • Hidden fields
  • Query string parameters
  • POST
  • Ajax call to the server
  • ...

It will all depend on how your application is organized, what kind of information is being stored, its volume, whether you want to redirect or not, ... But in all cases this should be done using javascript since that's the only way to access data stored in localStorage.

like image 88
Darin Dimitrov Avatar answered Nov 10 '22 01:11

Darin Dimitrov


No. The whole point of local storage is that it is local. One of the advantages of it over cookies is that you can store lots of data in it. One of the advantages of cookies is that they are tiny so the overhead of including them in every HTTP request to a given host is small. There two advantages are incompatible so you won't want them in a single technology.

If you want to get the data on the server, then you need to get the client to send it explicitly (e.g. via Ajax).

like image 11
Quentin Avatar answered Nov 10 '22 01:11

Quentin