ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Page / Active WEBDEV Pages and sites
  • Overview
  • How to?
  • To implement the management of AWP contexts via cookies:
  • To implement the management of AWP contexts on disk:
  • WLanguage functions for managing AWP contexts
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
To keep the value of global variables when switching from a page to another one, the AWP mode proposes a management of contexts.
Two modes are available for managing the contexts:
  • Managing the contexts via cookies: the value of the different variables is stored on the user browser via a cookie. This management mode presents several drawbacks:
    • the cookies must be supported by the browser of the Web user
    • the size of the cookies cannot exceed 4 KB
    • the security of the information stored in the cookie is not guaranteed.
  • Managing the contexts on disk: the value of different variables is stored in a file on the server. A context identifier is used to retrieve the context stored. This identifier can be stored via a cookie on the computer of the Web user or transmitted on the URL. This identifier guarantees the security of stored data.
Remark: If several AWP contexts are found on the same domain, these contexts are entirely independent. The identifier of the AWP context is unique per domain and per site.
How to?

To implement the management of AWP contexts via cookies:

  1. Use ConfigureAWPContext to specify the management mode of AWP context. This function should be used in the initialization process of project. Indeed, the selected mode cannot be modified when the session is started.
    To use the management of contexts via cookies, the following line of code can be used:
    ConfigureAWPContext(ctxCookie)
  2. Use DeclareAWPContext to store or get the value of the desired variables. This function should be used in the project initialization code (for the project variables) and/or in the initialization code of the pages (for page variables). In most cases, this function must be used in the process where the variables are declared and initialized.
Remarks: In this operating mode:
  • DeclareAWPContext uses the HTTP cookies. The values of variables will not be restored if the HTTP cookies are ignored by the browser used on the current computer.
  • The total size of values for the different variables cannot exceed 4KB. If the size of these values is too important, these values will be truncated (missing variable and/or truncated content).
  • DeclareAWPContext is not recommended for the sensitive data (user password for example). Indeed, the data flows via the browser. This function must NOT be used to store a user connection for example.
  • If two variables are saved with the same name (one in the project and the other one in a page for example), only the first variable will be stored.
  • DeclareAWPContext returns False if one of the variables was not restored.
  • Only the variables passed to DeclareAWPContext during a page display will be retrieved during the next display. The variables that were previously passed are not automatically saved again.
  • Only the simple variables (integer, string, ...) are supported.
  • A multi-file Upload control cannot be used with the AWP contexts whose type is cookie.

To implement the management of AWP contexts on disk:

  1. Use ConfigureAWPContext to specify the management mode of AWP context. This function should be used in the initialization process of project. Indeed, the selected mode cannot be modified once the session is started.
    To use the management of contexts on disk, the following line of code can be used:
    ConfigureAWPContext(ctxDisk)

    Remark: ConfigureAWPContext can also be used to define the transmission mode of the context identifier. This identifier can be transmitted:
    • By URL and cookie during the first start, then with the best possible mode (by cookie if cookies are accepted by the browser). This mode is the default mode.
    • By cookie only. In this case, the management of cookies must be enabled on the user's browser
    • By URL only. In this case, the identifier will always appear in the URL of pages.
  2. Use DeclareAWPContext to store the desired variables. This function should be used in the project initialization code (for the project variables) and/or in the initialization code of the pages (for page variables). In most cases, this function must be used in the process where the variables are declared and initialized.
    Remarks: In this operating mode:
    • DeclareAWPContext uses the contexts on disk. The values of variables are always restored.
    • The total size of values for the different variables is not limited.
    • DeclareAWPContext can be used for the sensitive data (user password for example).
    • If two variables are saved with the same name (one in the project and the other one in a page for example), the two variables are stored independently.
    • DeclareAWPContext returns False if one of the variables was not restored.
    • All variables passed to DeclareAWPContext during a page display can be retrieved during the next display. The variables that were passed beforehand are automatically saved again.
    • The simple variables (integer, string, ...) are supported as well as the structure, class, array or associative array variables. The fixed arrays, the associative arrays of local structures and the global members of classes are not supported.
    • The multi-file Upload controls can only be used with the AWP contexts on disk.
  3. To delete a specific variable from the context, you have the ability to use CancelAWPContext.
  4. IdentifierAWPContext is used to find out the context identifier of Active WEBDEV Page.
Remark: The WEBDEV administrator allows you to configure the duration for the validity of AWP contexts ("Duration of AWP contexts" in the "Configuration" tab). As soon as the specified duration is exceeded, and if no new request was performed, the context file is deleted.
Freeing the context on disk
The WEBDEV Application Server automatically protects each AWP context from the concurrent accesses :
  • At any time, a single AWP call is allowed to handle a given AWP context.
  • The other AWP calls that want to handle this context (which means the other calls from the same client/browser) wait for the first call to be over:
    • Eech call can access the last values.
    • The global operating mode is equivalent to the operating mode of standard WEBDEV sessions.
  • The AWP context is automatically freed (for the next call) after the execution of the last WLanguage process.
In some cases, this operating mode is not optimum.
For example, an Active WEBDEV Page for file download will continue to maintain the lock on the context during the entire execution of FileDisplay. This lock locks the other calls of the client to the application (downloading a second file in parallel for example).
In this case, AWP: Managing contexts indicates that the AWP context will no longer be used, so it can be freed.
WLanguage functions for managing AWP contexts
The following WLanguage functions are used to manage AWP contexts:
CancelAWPContextDeletes from the AWP context a variable that was added by DeclareAWPContext.
ConfigureAWPContextConfigures the operating mode of the AWP context.
DeclareAWPContextUsed to declare a list of variables whose value will be persistent between the successive displays of Active WEBDEV Pages.
FreeAWPContextFrees the AWP context in advance (on disk) to allow the other call on the same AWP context to be processed in parallel.
IdentifierAWPContextReturns the identifier of AWP context.
Minimum version required
  • Version 12
Comments
Click [Add] to post a comment

Last update: 01/26/2023

Send a report | Local help