Download Informix Web DataBlade Module Application Developer`s Guide

Transcript
Using Cookies
The following cookie AppPage determines whether or not the Web browser
has retrieved this AppPage previously. The first time the Web browser
retrieves the cookie AppPage, the AppPage sends a cookie to the Web
browser, which the Web browser keeps even if it retrieves other HTML pages
before retrieving this AppPage again. On any subsequent retrieval of this
AppPage, the browser displays the Welcome Back! message.
<HTML>
<HEAD><TITLE>Has the user been here before?</TITLE></HEAD>
<BODY>
<H2>Has the user been here before?</H2><HR>
<!--- See if the flag variable has been set --->
<?MIBLOCK COND=$(XST,$flag)>
<!--- Flag variable has been set --->
<B>Welcome Back! You have been here before!</B>
<?/MIBLOCK>
<?MIBLOCK COND=$(NXST,$flag)>
<!--- Flag variable has NOT been set --->
<!--- Set a cookie
--->
<?MIVAR>$(HTTPHEADER,set-cookie,flag=yes)<?/MIVAR>
<B>This is the first time you have been to this page!</B>
<?/MIBLOCK>
</BODY>
</HTML>
The following figure shows sample Web browser output the first time the
cookie AppPage is retrieved.
Web Browser - [Has the user been here before?]
URL: http:/domain:port/hr_app/?MIval=/cookie.html
Has the user been here before?
This is the first time you have been to this page!
13-6
Informix Web DataBlade Module Application Developer’s Guide
Figure 13-1
Cookie—First
Request