I am working on an app where a user can edit a “thing”. I don’t want multiple users to edit the same thing at the same time, so I’ve implemented a “locking” technique. It seems to be working fairly well. If you try to open a thing that is locked by someone else, you can view the thing, but in read-only mode.
To accomplish this, I am using window.sessionStorage, like this:
function sessionNumber() {
if (window.sessionStorage.sessionNumber) {
return window.sessionStorage.sessionNumber;
}
else {
var num = Math.floor(Math.random() * 100000000 + 1);
window.sessionStorage.sessionNumber = num;
return num;
}
}
In chrome, if you open the same “thing” in a different tab, you get a different session number. In Opera, if you open the same thing in a different tab, you get the same session number.
To be clear, I prefer Chrome’s behavior over Opera’s. Is there a cross browser way of accomplishing this?