Page 2 of 2

Re: echo example

Posted: Sat Apr 25, 2015 10:40 am
by rdonnay
Zdeno -

Here is an application I would like you to look at.
I handle session data within the form.

DD787.PRG is a program written for the USS James E. Kyes (DD-787) webpage
to allow association members to RSVP that they will be attending the next
reunion.

It is called as follows:

http://localhost:8080/dd787/rsvp

Add DD787.PRG to your CxpHttpServer.Xpj project file.

You can now make several simultaneous connections to the server on different tab pages and form data will be handled correctly.

If you need to store login info or handle session timeouts, this can be done with hidden variables that are part of the form.

I will work on updating the program to show how to do that as soon as I have some more time available.

Re: echo example

Posted: Sat Apr 25, 2015 11:11 am
by bwolfsohn
Roger,

We struggled with session management for many years (over a decade) using xb2net. (not xb32net's problems, but problems in our approach. We finally fixed it on 2012, and haven't had any problems since... So few problems, i had forgotten how we handled it, because i haven't looked at the session management code since then!!! We handle upward of 300 legitimate very active sessions frequently. I'll be glad to go over our methods at the express++ devcon in a week...

Even though we use xb2net for our webservers, the approach we use will still fit within pure alaska (presuming they support the webserver functions needed

Re: echo example

Posted: Sat Apr 25, 2015 11:34 am
by rdonnay
I'll be glad to go over our methods at the express++ devcon in a week...
I'm looking forward to that.
I hope to spend half the time on internet stuff.
This is becoming too important for most Xbase++ developers.
There are simple approaches to most of the needs.
Your app goes way beyond what most of our needs are but it shows what is possible.

Re: echo example

Posted: Sat Apr 25, 2015 4:56 pm
by rdonnay
Here is a much better version of DD787.PRG and RSVP787.HTM.

This is fully object-oriented now. It still has a DD787 class and a RSVPForm class but it is better structured.

RSVP787.HTM now contains a HIDDEN variable named timestamp and RSVPForm also contains an iVar named timestamp.

RSVPForm:getAllVars() now stores the current time as Str(Seconds()) into timestamp which in turn is embedded in the form by RSVPForm:stuffVars().

When the form is submitted to the server, the value of timestamp in the form is checked against the current time on the server.
If the user has not submitted the form within 5 minutes of it being sent to the browser, a timeout message will show in the form and the user must reenter all data. This is an example of session management. Test it by running localhost:8080/dd787/rsvp on several tabs simultaneously.

This technique can also be used for login information such as user id or password and this info can be embedded as hidden variables in the form.

This updated code is a better framework for simple projects such as filling in a form and having it save the data to a database or send it to the office by email. The only thing I don't like about it yet is that the form must use a GET instead of a POST. This is supposed to be fixed by Alaska Software.

Re: echo example

Posted: Sun Apr 26, 2015 7:42 am
by Zdeno Bielik
Roger,

many thanks for next example, I will look at it.

Zdeno