Tracking Users Using WML
Tying It All Together
Now that we can set and retrieve cookies, what exactly do we do with them? As stated earlier, we could store a variety of information in cookies for use in helping the user interface when the visitor returns to our site.
In the earlier restaurant example, for instance, you could utilize the following cookies:
|Phone-Number:||Device phone number|
|Zipcode:||Target ZIP code for restaurant matches|
|Genre:||User's favorite type of food|
Alternatively, you could encode all this data into one lengthy string.
My advice, however, would be to tie one unique piece of data that identifies the user to a database record. Basically, store only what you need on the client device, and store the rest of the data in a database accessible by the server. The flowchart for an application using this method might resemble Figure 2.
Click here for larger image
Figure 2 - Flowchart of application using described method
On entering the site, the user's browser is checked for an ID cookie. If the cookie is found, the user's preferences are retrieved from the server's database and the site is displayed with those preferences. If the cookie is not set, the user is taken to a preference form and queried for his/her preferences. Those preferences are stored in the server's database and the user's ID is stored as a cookie.
What Do You Want from WML?
I'm interested in hearing what you need/want to do with WML. I'll use some of the more challenging or common ideas in upcoming articles. Send your ideas to the address below.
About the Author
Steve Schafer is the chief operating officer of Progeny Linux Systems, a Linux-based consulting company in Indianapolis, Indiana. He has written several technical books and articles and can be reached at email@example.com.
# # #
Page 5 of 5