1

I was wondering if it is possible to keep some data even after refreshing the page. For example, I have values in my array and I don't want to lose them after refreshing the page.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ahmet Tanakol
  • 849
  • 2
  • 20
  • 40
  • If you add more information on your use case, we can better specify a solution for you. All the answers below will work, but some solutions are better than others depending on the scenario. – rkw Jul 24 '12 at 07:59

5 Answers5

4

Use Cookies in javascript or the HTML5 localStorage,sessionStorage variable .

To use HTML5 LocalStorage, simply use it like variable preceded by localStorage.

localStorage.variable=['wrg','wg','wg'];

To use HTML5 sessionStorage, simply use it like variable preceded by sessionStorage.

sessionStorage.variable=['wrg','wg','wg'];

For more Info See Here

Community
  • 1
  • 1
bugwheels94
  • 30,681
  • 3
  • 39
  • 60
2

I have used jStorage in the past for storing data, its uses HTML 5 local storage where available and falls back to other methods when needed.

$.jStorage.set(key, value, options)

value = $.jStorage.get(key)
value = $.jStorage.get(key, "default value")
tsukimi
  • 1,605
  • 2
  • 21
  • 36
1

There is a trick w/ window.name in some browsers which allows to keep data even after refresh. Window name can store a json of your array.

window.name = "[JSON]";

BTW, Dojo implemented wrapper around window.name Dojo WindowName

Raman Zhylich
  • 3,537
  • 25
  • 23
0

Set a cookie with your values and request the cookie.

pat34515
  • 1,959
  • 12
  • 13
0

One way is to create Cookie and store in it $.cookie("SomeKey", 1);

HatSoft
  • 11,077
  • 3
  • 28
  • 43