PDA

View Full Version : Maintaining state between Lianja WebView requests



barrymavin
2012-11-01, 05:17
One of the interesting features of the Lianja Cloud Server which handles web page requests is that unlike many other web servers it does not have to be stateless.

If for example you want to save the current "state" e.g. what database do I have open, what tables do I have open, what are the active records and their properties such as EOF(), FOUND(), BOF() it can be done like this:



save datasession to m_state


Then to restore the state you can just do this.



restore datasession from m_state


When a web page request completes, the Lianja Cloud Server keeps track of an active session using a cookie which it sends back to the browser. This cookie identifies the "session" so on the next web page request the "session" can automatically be restored in order to maintain state between requests.

The _session associative array (object) can be used to "save state" of variables also. So prior to exiting the page request all you need to do is this.



save datasession to m_state
_session["state"] = m_state
m_customer = "John Smith"
_session["customer"] = m_customer


And then restore the state back on entry to the .rsp page on the next page request.



if type( _session["state"] ) != "U"
m_state = _session["state"]
restore datasession from m_state
m_customer = _session["customer"]
endif