Date:  12/10/2007 10:37:11 AM Msg ID:  003620
From:  FoxWeb Support Thread:  003619
Subject:  Re: Javascript and Session.SetVar

The first thing I would like to ask you is if the data needs to be in a session variable to begin with.  In general, session variables should hold data that is not specific to any one page, but rather applies to the whole application.  In other words, if the user were to use the back button, session data should still be applicable. 

Examples of information that is suitable for session variables:

Examples of information that is not suitable for session variables:

Assuming that your particular situation calls for the use of session variables, now you have to find a way to send the data in question to the server.  JavaScript code runs on the browser, so it can't interact directly with the FoxWeb API.  The only way to set up a session variable from JavaScript code is by making a connection back to the server.

Does the data need to go to the server immediately, or can it wait until the user makes another request to the server?  If it can wait, then one possibility, would be to be to store this data in a JavaScript variable that gets submitted to the server via the query string, or hidden form field when the user clicks on a control (hyperlink, or form submit button) that causes a server connection.

Another possibility is to use Ajax, which allows HTTP requests to be made asynchronously in the background.  For information and examples on the use of Ajax, search this forum, or the web.  Ajax is primarily a client side technology, so it's not FoxWeb-specific.  Also, FoxWeb 4 comes with an Ajax example (ZipSearch).

FoxWeb Support Team
support@foxweb.com email
Sent by George Gambill on 12/10/2007 05:20:22 AM:
Is there a way to set a session variable with JavaScript such that FoxWeb can retrieve that variable with the session.getvar command?