Monday, December 8, 2014

Session in javascript across pages.


 Some days back I had to implement a small feature in one of our company application. Had to think a while on how I could achieve that. Finally I end up solving the issue by smartly using Ajax and global variables. My intention here is not to give you code (at least you request it) but rather to present some ways around on solving such a matter. Taking the following point into consideration may help you dilute the situation:

  1.  Ajax: Asynchronous JavaScript and XML. AJAX is the art of exchanging data with a server, and updating parts of a web page - without reloading the whole page.
  2. Global variables
  3. The localStorage Object: The localStorage object stores the data with no expiration date. The data will not be deleted when the browser is closed, and will be available the next day, week, or year. e.g
  4. The sessionStorage Object: The sessionStorage object is equal to the localStorage object, except that it stores the data for only one session. The data is deleted when the user closes the browser window. e.ghttp://www.w3schools.com/html/html5_webstorage.asp

Feel free to share your experience or feedback with us.

No comments:

Post a Comment