|
Techniques for setting, retrieving and deleting cookies without using a digest
Introduction The UP.SDK includes libraries that will help you include cookies in a digest that is sent to an UP.Browser. However, you may not wish to use a digest, you may wish to set your cookies manually, and you may do this in exactly the same way you would set a cookie when sending an HTML page to a web browser. This technical note and companion sample application describe how to set, retrieve and delete cookies without using the UP.SDK digest libraries. The application comprises plainCookie.cgi and deleteCookie.cgi. Please try the demo URL to see how they work: http://demo.openwave.com/cookie/cookie.wml. NOTE: The example code included with this technical note is written in WML 1.1 and Perl, and is portable to any platform with a Perl interpreter.
Let's take a close look at these source codes. The plainCookie.cgi Source Code The application is comprised entirely of three cards:
Control of the application is maintained by the values which are returned in the QUERY_STRING HTTP Header. The value of the NEXT variable dictates which card should be returned by the script, and if there is data associated with the "name" variable, then a cookie is set. The cookie is actually set by including the following line in the HTTP response from the script:
The next time the script is invoked (as you navigate to card 3) the cookie is returned to the server along with the HTTP request for card three. The script parses the cookie information with the following code:
and substitutes it in with the third card:
The deleteCookie.cgi Source Code
|
