Where does VBFORUMS save the "text" of a post when it does that AUTOSAVE??
So - you know how when you are posting a thread like this - every now and then you see an AUTO-SAVED charm appear in the lower-right corner.
Where does it save this text?
I would like to implement something similar in my own web app - so that if an AJAX request to save a big note to the server fails the user can simply recover the last text.
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Re: Where does VBFORUMS save the "text" of a post when it does that AUTOSAVE??
I just checked my cookies for VBF and didnt see any cookies for auto save. I assumed it was saved in the database using AJAX.
Also doing some research, it seems that Administrators are able to delete everything that is auto-saved from their end, which would point toward database opposed to cookies.
Re: Where does VBFORUMS save the "text" of a post when it does that AUTOSAVE??
I can give you the cookie settings:
Code:
function getCookie(c_name) {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g, "");
if (x == c_name) {
return unescape(y);
}
}
}
function setCookie(c_name, value, exdays) {
var exdate = new Date();
//exdays = 99;
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
function deleteCookie(name) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
You can also set them from server side but i guess this is something you wouldn't like
P.S. Notice the .toUTCString() . This is vital if you want to work with Iexplorer !
Last edited by sapator; Jul 31st, 2014 at 05:51 AM.
Reason: hatred addition for Iexplorer
Re: Where does VBFORUMS save the "text" of a post when it does that AUTOSAVE??
I would guess it might use LocalStorage. The alternative would be cookies, accessed through document.cookie, but cookies have very low storage space in comparison.
For data that doesn't need to get sent back to the server, LocalStorage is the way to go. The data should (barring any browser bugs) be restricted-access from the DOM via Same-origin policy, so you can't access LocalStorage data for another domain. Each origin will usually get 5 megabytes of storage space.
Cookies are transmitted on every request going to-from the server, and that includes all assets (js, css, images, etc.) individually. This is why most large websites retrieve their assets from a separate domain that doesn't set any cookies. Individual cookies are limited to 4 kilobytes data.
EDIT: dclamp might also be correct with the AJAX auto-saving.