#!/usr/local/bin/perl5.001 ###################################################################### # AppUtils Loading and Configuration ###################################################################### # Include the apputils directory which has all the SDK utilities BEGIN { push (@INC, "../apputils"); } # Path to SDK apputils # Load required application utilities require 'DeckUtils.pl'; # Just for parsing of HTTP QUERY_STRING ###################################################################### # Cookie Retrieval ###################################################################### # Split each cookie pair out of the header string # @nvpairs=split(/[,;] */, $ENV{'HTTP_COOKIE'}); # To extract the value from a specific cookie: # foreach $pair (@nvpairs) { ($name, $value) = split(/=/, $pair); $cookie{$name} = $value; } # # Parse the CGI Vaiables # %cgiVars = &AppUtils::ParseCGIVars(); # # WML DECKS FOLLLOW # # # The XML Prologue and WML DTD # $header= ' '; # # This deck resets the name variable when loaded. # It takes user input and passes it back to this script via QUERY_STRING # $deckOne= '

Enter name:

'; # # # This deck gets sent when the cookie is set as a confirmation # $two='

I am cookie-ing you as '.$cgiVars{"name"}.'

'; # # The cookie is retrieved and displayed with this deck. TTL is 0 on this deck, so it # is never reloaded from the chache. If it is loaded from chache, it might # display a value that is different than the current cookie # $three='

I picked up the cookie you as '. $cookie{"you"} .'

'; # # # Decide which deck to serve depending on the vaule of 'NEXT' # if ($cgiVars{"NEXT"} eq "two"){ $deck=$two; } elsif ($cgiVars{"NEXT"} eq "three"){ $deck=$three; } else{ $deck=$deckOne; } &deckDump; ####################################### # # Output a deck, Including cookie info # ###################################### sub deckDump { # Output the content type print "Content-type: text/vnd.wap.wml \n"; # Check to see if name was passed in, if so cookie it, as 'you' # otherwise, don't cookie if ($cgiVars{"name"} ne ""){ print "Set-Cookie: you=".$cgiVars{"name"}."\n"; } # Output the data print "\n"; print $header; # Print out the xml prologue and DTD print $deck; # Print out the deck }