// cookiedemo1 - set a cookie to hold the current date and time..
//
// Note: when setting a cookie the Set-Cookie statement must be the FIRST displayable line
// and it can have no leading white space.
//
// load action parameter if any..
#cgivar action
//
//
#if @action = clear
  // set cookie to ""
  #+ Set-Cookie: QUISPCOOKIE=; path=@CGIPROG; expires=Friday, 31 Dec 2010 10:10:10 GMT
  //
#elseif @action = set
  // set the cookie to current date.time
  #call $setdatefmt( Mmm-dd-yyyy )
  #set today = $todaysdate()
  #set now = $time()
  #set cookie_value = "Last-visit:" @today "." @now 
  #+ Set-Cookie: QUISPCOOKIE=@cookie_value; path=@CGIPROG; expires=Friday, 31 Dec 2010 10:10:10 GMT
#endif

#set TITLE = "cookie demo"
#include top
<center>

#if @action = get
  // load the cookie..
  #cookie QUISPCOOKIE
  <h3>Cookie value is: <font color=D00000> @QUISPCOOKIE </font></h3>
#endif


#if @action = clear
  <h3>Cookie has been cleared.</h3>
#elseif @action = set
  <h3>Cookie has been set to the current date & time.</h3>
#endif

<br>
<br>
<a href="?rtn=cookiedemo1&action=get">Display the cookie</a> &nbsp; &nbsp; &nbsp;
<a href="?rtn=cookiedemo1&action=set">Set the cookie</a> &nbsp; &nbsp; &nbsp;
<a href="?rtn=cookiedemo1&action=clear">Clear the cookie</a> 

<br>
