Monday, August 29th, 2005

Internet Explorer Has Native Support for Persistence and Saving Session Across Page Loads Without Cookies

Category: Articles, IE

>Brad Neuberg has written up a lot on the state of state in the browser :)

Saving Session Across Page Loads Without Cookies, On The Client Side

This is a mini-tutorial on saving state across page loads on the client side, without using cookies so as to save large amounts of data beyond cookies size limits.

He discusses two ways to deal with session state in the client:

  • Method number one is to use an iframe in some special ways. First, this iframe must exist on page load, Then, whenever you wish to record state that you want to save, you must write that state into the iframe
  • The other session approach I’ve found is a crazy hack that I saw used for something else, in Danny Goodman’s book JavaScript and DHTML Cookbook. Danny was looking for a way to pass data between frames, and he found that you could persist data by saving them into hidden text fields. This is a beautiful (and scary) hack that is a solution to our session state. All the browsers I have tried (IE, Firefox, and Safari) persist any text you put into a form field, even if they are hidden. To save state, then, we can simply write it into hidden form fields!

Run a demo

Internet Explorer Has Native Support for Persistence?

How the heck did I miss the existence of non-cookie persistence features in Internet Explorer since IE 5? This is from MSDN:

“Persistence enables authors to specify an object to persist on the client during the current and later sessions using Dynamic HTML (DHTML) behaviors. Persistence allows Microsoft Internet Explorer 5 and later to retain Web page information, styles, variables, and state. For example, a collapsible list of links within a table of contents can remain expanded to the user’s choice upon leaving and later returning to the page. Or, a search engine query form can retain the last-used searchstring.

Related Content:

Posted by Dion Almaer at 3:36 am
3 Comments

++++-
4 rating from 7 votes

3 Comments »

Comments feed

A few other articles on IE data persistance are from 1) Ajaxian – “Client-side state in IE… what about Mozilla?” (http://www.ajaxian.com/archives/2005/06/clientside_stat.html) and 2) Jordan Frank – “talk about getting nothing for something…” (http://blogs.ebusiness-apps.com/jordan/index.php/3/)

Comment by Dave Johnson — August 29, 2005

Good tip, but doesn’t solve the problem, how to persist data between requests to the same page? This only seems to work when refreshing the page. For example, I have an onUnload handler, which examines form fields and in some cases doesn’t allow directing to new page, but rather goes back to original page (this is done with location=self.location), which should show the persisted data. I don’t know if this possible without 1) going to the server, 2) passing parameters in URL or 3)…?

Comment by Janne M. — December 28, 2006

3) Make a frameset with two horizontal frames, the first one 1 pixel high, where you load a static page with a background matching the top of the website graphic layout. Your dynamic content (actually, your entire site) goes into the lower frame (even if another frameset). In the frameset itself, put JS code defining as many variables you want to make them persistent. Address those variables from the rest of your pages with the top. prefix. They will last for as long as the original frameset doesn’t change.

Comment by MAD — November 7, 2007

Leave a comment

You must be logged in to post a comment.