home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13h.zip / SAMPCOOK.RX0 < prev    next >
Text File  |  1998-01-12  |  1KB  |  42 lines

  1. /* 12 Jan 1998
  2.   This is a simple demonstration of  the use of cookies with SRE-http.  */
  3. /* To use it, put the following line in your html document:
  4.   <!-- interpret file sampcook.rxx -->
  5. (and be sure this file is in your SRE-http ADDON directory") 
  6. */
  7.  
  8. /* If "send in pieces" selected, the adding to header is impossible, so
  9.    we have an ERROR! */
  10. if  send_piece=1 then do
  11.   queue "<strong> ERROR: </strong> SRE-http can not set cookies using SSI's "
  12.   queue ' when  <strong> DO_SEND_PIECE="YES" </strong>!'
  13. end
  14.  
  15. else do
  16.  
  17. /* determine if we have a "LAST_ACCESS" cookie */
  18.   tmp.say=sref_get_cookie('LAST_ACCESS',1)
  19.   if tmp.say=' 'then
  20.      tmp.say='This is your first access to  ' docname
  21.   else
  22.     tmp.say=' Last access to ' docname ' was on: ' tmp.say
  23.   queue tmp.say
  24. /* write out all cookies */
  25.   tmp.cookies=reqfield('cookie:')
  26.   queue " <hr> Note that your cookies are: <br> <b> " tmp.cookies "  </b> <p> "
  27.  
  28. /* check on browser */
  29.   tmp.!browser=reqfield('User-agent:')
  30.   tmp.!docook=sref_browser_info('COOKIES')
  31.   if tmp.!docook<>'YES' then
  32.      queue '<br> Our info shows that your browser ('tmp.!browser ') does <b>not</b> understand cookies!<br> '
  33.   else
  34.      queue '<br> Our info shows that your browser ('tmp.!browser ') <b>does</b> understand cookies! <br>'
  35.  
  36.  
  37. /* add a "LAST_ACCESS" cookie for  the invoking URL */
  38.   boo='last_access='||date()' 'time() ' ; path=/'|| docname
  39.   'header add set-cookie: '|| translate(boo,'_',' ')
  40.  
  41. end
  42.