Another web challenge: state

Andre Garzia andre at andregarzia.com
Fri Sep 23 15:34:03 EDT 2011


> This issue came to light in a thread I came across in the RB forums, eager
> as I am to learn more about their implementation.
>
> This thread notes how Dreamhost -- where I run a great many Rev CGIs,
> including the blog at LiveCodeJournal.com -- recently nixed an RB app
> because it was attempting to maintain an open socket:
> <http://forums.realsoftware.**com/viewtopic.php?f=23&t=40397<http://forums.realsoftware.com/viewtopic.php?f=23&t=40397>
> **>
>
>
>

Andre: "I guess FastCGI Server are not that fast ..."
Andre picks dark sun glasses
Andre: "... when they are not running!"
YYYEEEAAAAAHHHH!!!! Cue CSI Music....


I told you guys I bet they were using FastCGI to maintain state and that
this was one of the hardest things to do...

Now speaking about maintaining state or my quest for LiveCode to implement
introspection thru closures and continuations. If we had a way to freeze the
computation in time like saving a game, then we could save and restore those
computation pathways with each web request. From the server point of view,
each client would be unique and a straight flow because requests could be
abstracted. If we have a way to save the memory content (Variables,
contexts...) and we save/restore with every request, the whole state
maintaining problem goes away. Squeak Web Framework called Seaside does
exactly that. It captures the computation, saves it to a session and sends
the output back, with each request, it restores the session and the
computation and goes on. Very cool and makes the stateless web, something
that looks stateful.

My current way of keeping state is by using a unique id as a cookie. This
unique id is also the name of a file in the hard drive so if the unique id
is "ASDFG" then there is a file like "/sessions/sess_ASDFG" which is an
arrayencoded text file. When the CGI launches, it reads and decodes this
array. It does whatever it needs to be done, writes the array back. This is
one of the ways that PHP $_SESSION works, it is simple to implement and the
data is not shared with the browser like storing things in the cookies
themselves. You can also use localStorage these days to keep stuff at the
client.

Cheers
andre





-- 
http://www.andregarzia.com All We Do Is Code.



More information about the use-livecode mailing list