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
  • 34,719
  • 24
  • 185
  • 251
Ahmet Tanakol
  • 831
  • 2
  • 20
  • 38
  • 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
  • 28,872
  • 3
  • 36
  • 59
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,595
  • 2
  • 19
  • 35
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,336
  • 23
  • 22
0

Set a cookie with your values and request the cookie.

pat34515
  • 1,939
  • 12
  • 13
0

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

HatSoft
  • 10,913
  • 3
  • 27
  • 43