Hi all,
This is a question of best practice -- ie. this is a problem which any serious website must have overcome, but about which I can find very little on the web. So I'd like to hear about some solutions people have used!
Most articles about achieving persistent variables (ie. that last from one request to the next) mention hidden variables and session variables. However, few mention the implications of the fact that users can be using multiple webbrowser instances.
There seem to me to be three types of persistent variables in a complicated application:
1) Simple page-specific variables, such as whether a list of items is expanded or not. Hidden form variables are ideal here.
2) Variables that describe a user, and are constant for an entire session, such as username, password, etc. Normal session variables are ideal here.
3) THE TRICKY ONES:
Variables which are, well, variable, but which are security sensitive and/or long, and so shouldn't really be appearing in hidden variables. For example, database primary key values for records that are being edited.
The problem comes when a user uses multiple instances of a browser, or the back button a lot. Then if these are stored as simple session variables, one could very easily land up using the incorrect primary key (eg from browser instance A) to UPDATE data submitted from, say instance B.
The only way I can see out of this is to send with each page request a random, unique key (not unlike a session id), which refers to a PART of the session. Then variables of type 2 are normal session variables, and type 3 are put into this unique part of the session, which is flushed and re-created with each request.
Is this really the best method???
Thanks,
Paul