Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Persistent Data - Retaining Session Context 1

Status
Not open for further replies.

friendlyposter

Programmer
Nov 1, 2002
61
US
Peersistence is to keep something for reference while the user (or the script) goes from page to page.

javascript sometimes needs to retain data and cannot always resort to one method e.g. server-side data retention.

The forum has no FAQ I could found giving best practices for retaining data between web pages.

There are so many possibilities - most of which are overkill for a small data item - and some of which rely on cookies that the user may not want - and even some that rely on a user login and a server-side data base keeping data in a user profile.

I have seen
- cookie data
- hidden INPUT items with data kept in form fields
- hidden frames
- visible frames that have input values or HTML spans or variables set that are kept unchanged as subframes change
- use of the URL (even the #href) to keep limited encoded data

Can we share your own thoughts ... or your awareness of good source material.

It's not just about new tricks - it's about guidelines and best practices and when to use each of the various methods.

 
However you get your data from one page to the next is up to you. There isn't really a set - correct - way of doing this.

There are, however, a couple of ways that you know will work with every browser. Which is the trick, these days.

I pass my data around in the URL (with the ?&= context like a server side call) or - and this is the one most people use - in a hidden field of a form on the page.

Of all the methods, when using a pure javascript enviroment, the hidden form field is my personal favourite.



Yet another unchecked rambling brought to you by:
Oddball
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top