【目录】 【上一页】 【下一页】 【索引】
Contains data specific to an individual client.
You cannot use the client object on your application's initial page. This page is run when the application is started on the server. At this time, there is not a client request, so there is no available client object.
All requests by one client use the same client object, as long as those requests occur within the lifetime of that client object. By default, a client object persists until the associated client has been inactive for 10 minutes. You can use the expiration method to change this default lifetime or the destroy method to explicitly destroy the client object.
Use the client object to maintain data that is specific to an individual client. Although many clients can access an application simultaneously, the individual client objects keep their data separate. Each client object can track the progress of an individual client across multiple requests to the same application.
示例 1. This example dynamically assigns a customer ID number that is used for the lifetime of an application session. The assignId function creates an ID based on the user's IP address, and the customerId property saves the ID.
<SERVER>client.customerId = assignId(request.ip)</SERVER>
See also the示例 for the project object for a way to sequentially assign a customer ID.
示例 2. This example creates a customerId property to store a customer ID that a user enters into a form. The form is defined as follows:
<FORM NAME="getCustomerInfo" METHOD="post">
<P>Enter your customer ID:
<INPUT TYPE="text" NAME="customerNumber">
The following code assigns the value entered in the customerNumber field from the temporary request.clientNumber to the more permanent client.customerId:
project, request, server
The client object has no predefined properties. You create custom properties to contain any client-specific data that is required by an application. The runtime engine does not save client objects that have no property values.
You can create a property for the client object by assigning it a name and a value. For example, you can create a client property to store a customer ID at the beginning of an application so a user does not have to enter it with each request.
Destroys a client object.
If you are using client-cookies to maintain the client object, destroy eliminates all client property values, but it does not affect what is stored in Navigator cookie file. Use expiration with an argument of 0 seconds to remove all client properties stored in the cookie file.
When using client URL encoding to maintain the client object, destroy removes all client properties after the method call. However, any links in a page before the call to destroy retain properties in their URLs. Therefore, you should generally call destroy either at the top or bottom of the page when using client URL maintenance.
The following method destroys the client object that calls it:
Specifies the duration of a client object.
Use the expiration method to explicitly control the expiration of a client object, making it longer or shorter than the default. You must use expiration in each page of an application for which you want a client expiration other than the default. Any page that does not specify an expiration will use the default of 10 minutes.
Client expiration does not apply if using client URL encoding to maintain the client object. In this case, client properties are stored solely in URLs on HTML pages. The runtime engine cannot remove those properties.
The following example extends the amount of client inactivity before expiration to 1 hour. This code is issued when an application is first launched.
【目录】 【上一页】 【下一页】 【索引】