20.4. Clearing Variable
Values (Passwords and Personal Data)
WML
variables have a global scope. Once you have set the value of a
variable, you can read it in any cards and decks, including cards and
decks of another WAP site. If you store a password or some personal
data in a variable, you should clear it after use.
Clearing
the value of a variable is straightforward. Just assign an empty
string to the variable using a way we discussed in the earlier
section "Setting Variable
Values in WML". Here is an example that makes use of the <setvar/>
tag to clear a variable:
<setvar
name="var1" value=""/>
20.4.1. The newcontext
Attribute
The
newcontext attribute of the <card> tag can also be used
to clear variable values. The value of the newcontext
attribute can either be true
or false (default value).
If it is specified to true, the WAP browser will reset
to the initial state. The navigational history and all WML variables
will be cleared as a result. One drawback of using the newcontext
attribute to clear variable values is that a user will not be
able to go back to a previous card, since the navigational history is
removed.
The
newContext() function of WMLScript's WMLBrowser standard
library does the same thing as the newcontext
attribute. The newContext()
function does not take any parameters. To call it, just place
the line below in a WMLScript function:
WMLBrowser.newContext();
Feedback Form ( ExpandCollapse)
|