$! 15-APR-1999 MGD refinements $! ??-???-1997 MGD lost in the mists of time $! set verify $! show symbol www_* $ say = "write sys$output" $! $ CookiePath = WWW_SCRIPT_NAME + "/" $! $ if f$type(WWW_HTTP_COOKIE) .NES. "" $ then $! (process a cookie sent from the client) $ Location = f$locate("WASD_COOKIE_DEMO",WWW_HTTP_COOKIE) $ if Location .lt. f$length(WWW_HTTP_COOKIE) $ then $ Cookie = f$extract(Location,999,WWW_HTTP_COOKIE) $ Cookie = f$element(0,";",Cookie) $ Cookie = f$element(1,"=",Cookie) $ CookieCount = f$integer(f$element(0,"_",Cookie)) $ CookieTime = f$element(1,"_",Cookie) + " " + f$element(2,"_",Cookie) $ else $ CookieCount = 0 $ CookieTime = "" $ endif $ else $ CookieCount = 0 $ CookieTime = "" $ endif $! $ if WWW_PATH_INFO .eqs. "/reset" $ then $! (reset the cookie by providing expiry date in the past) $ say "Content-Type: text/html" $ say "Set-Cookie: WASD_COOKIE_DEMO=''Cookie'; path=''CookiePath'; " + - "expires=""Fri, 13-Jan-1978 14:00:00 GMT""" $ say "Expires: Fri, 13-Jan-1978 14:00:00 GMT" $ say "" $ say "" $ say "" $ say "Cookie Reset Demonstration" $ say "" $ say "" $ say "Done!" $ say "" $ say "" $ exit $ endif $! $!(create cookie to send back to client) $ CookieCount = CookieCount + 1 $ DateTime = f$time() $ if f$extract(0,1,DateTime) .eqs. " " - then DateTime = "0" + f$extract(1,99,DateTime) $ Date = f$element(0," ",DateTime) $ Time = f$extrcat(0,8,f$element(1," ",DateTime)) $ Cookie = "WASD_COOKIE_DEMO=''CookieCount'_''Date'_''Time'; path=''CookiePath'" $! $!(HTTP response including cookie and HTML page) $ say "Content-Type: text/html" $ say "Set-Cookie: ''Cookie'" $ say "Expires: Fri, 13-Jan-1978 14:00:00 GMT" $ say "" $ say "" $ say "" $ say "Cookie Demonstration" $ say "" $ say "" $ say "

Cookie Demonstration

" $ if f$type(WWW_HTTP_COOKIE) .EQS. "" $ then $ say "This is the first time you have used this demonstration." $ say "

Use it again straight away!" $ else $ say "You have used this demonstration ''CookieCount' times;" + - "  Last at  ''CookieTime'" $ say "

The cookie returned was:

  ''WWW_HTTP_COOKIE'
" $ say "

The cookie set this time was:

  ''COOKIE'
" $ say "

The demonstration was produced using " + - "" + - "this very simple DCL CGI script!" $ say "

Reset the cookie" $ say " (IE4 doesn't seem to want to do this!)" $ endif $ say "" $ say ""