...

View Full Version : Do you use other ways for persistence other than cookie?



Code Wizard
01-02-2004, 01:51 PM
And I don't mean hte other `traditional' ways like URL manipulation,or hidden form fields...

There are other ways to persist data other than cookies,these apply in IE,and they are implemented as behaviors;they are:
saveFavorite
saveHistory
saveSnapshot
userData(this one reffers to some XML stuff)

A1ien51
01-02-2004, 03:21 PM
It is called server side language with a database.


IE only with ActiveX with writing to text file

Code Wizard
01-02-2004, 03:34 PM
D'OH I forgot to say that this poll refers to client-side scripting not server side...

Roy Sinclair
01-05-2004, 09:26 PM
Originally posted by Code Wizard
D'OH I forgot to say that this poll refers to client-side scripting not server side...

If you don't use server-side then you're limited to cookies for anything you want to be able to keep past the current session. If the current session is the only need you can add form fields and the URL itself as possible storage locations.

fredmv
01-05-2004, 09:33 PM
The window object's name property. ;)

http://www.webxpertz.net/forums/showthread.php3?s=&threadid=26736

glenngv
01-06-2004, 08:57 AM
If you are using frames, modifying window.name might affect page targetting.

A much better solution is to use window.navigator object instead:


<html>
<head>
<script type="text/javascript">
window.navigator.num=(window.navigator.num) ? window.navigator.num+1:1;
alert(window.navigator.num);
</script>
</head>
<body>
Refresh the page to see that variables persist.
</body>
</html>

glenngv
01-06-2004, 09:27 AM
Moreover, you can create persistent arrays:


<html>
<head>
<script type="text/javascript">
window.navigator.num=(window.navigator.num) ? window.navigator.num+1:1;
if (window.navigator.arr && window.navigator.arr.length>=0)
window.navigator.arr[window.navigator.arr.length]=window.navigator.num;
else
window.navigator.arr = new Array();

var temp='';
for (var i=0;i<navigator.arr.length;i++){
temp += navigator.arr[i] + '\n';
}
alert(temp);
</script>
</head>
<body>
Refresh the page to see that variables persist.
</body>
</html>

fredmv
01-06-2004, 08:15 PM
Even better, didn't even think of that Glenn.

Roy Sinclair
01-06-2004, 08:50 PM
glenngv,

Does that work in all browsers or just a select few?

glenngv
01-07-2004, 01:23 AM
Tested with all the browsers in my machine - IE5.5, NS7.02, NS4.78 and Mozilla 1.0 and it all works except for NS7. :confused:

jkd
01-07-2004, 02:44 AM
Does anyone else find this just a little disconcerting, or is it just me?

Somebody should check in Mozilla 1.4+. Wouldn't surprise me if this was removed in 1.01 and greater (NS7) simply due to the very iffy reach beyond the sandbox this has.

If it persisted, you could do ugly stuff like:

navigator.__defineGetter__("userAgent", function() {
// do code to steal cookies and submit a form or something
});

Or anything like that.

Roy Sinclair
01-07-2004, 02:36 PM
Moz 1.4 rejects it.

brothercake
01-07-2004, 03:45 PM
Originally posted by jkd
Does anyone else find this just a little disconcerting, or is it just me?
No it's not just you :(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum