home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / Cookie_JScript.asp < prev    next >
Text File  |  1997-10-25  |  2KB  |  63 lines

  1. <%@ LANGUAGE = JScript %>
  2.  
  3. <%
  4.     // Changes to the HTTP response header, in which cookies
  5.     // are sent back to the client, must be made before
  6.     // sending any data to the user.
  7.     
  8.     Response.Expires = 0;
  9.     
  10.     
  11.     // Get the last visit date/time string from the cookie that
  12.     // resides in the http request header.
  13.     
  14.     var LastVisitCookie;
  15.     LastVisitCookie = Request.Cookies("CookieJScript");
  16.     
  17.     
  18.     // Send the current date/time string in a cookie enclosed
  19.     // in the response header.  Note that because IE now uses
  20.     // case-sensitive cookie paths, we have explicitly set
  21.     // the cookie path to be that of the url path to this
  22.     // page.  By default, the path would be that of the
  23.     // IIS Application context for this page ("IISSAMPLES")
  24.     
  25.     var CurrentDate = new Date();
  26.     Response.Cookies("CookieJScript") = CurrentDate.toLocaleString();
  27.     Response.Cookies("CookieJScript").Path = "/IIsSamples";
  28. %>
  29.  
  30. <HTML>
  31.     <HEAD>
  32.         <TITLE>Using Cookies</TITLE>
  33.     </HEAD>
  34.  
  35.     <BODY BGCOLOR="White" topmargin="10" leftmargin="10">
  36.  
  37.         <font size="4" face="Arial, Helvetica">
  38.         <b>Using Cookies</b></font><br>
  39.       
  40.         <hr size="1" color="#000000">
  41.         
  42.         <%
  43.             if (LastVisitCookie == "") 
  44.             {
  45.                 // The cookie has never been set. This must
  46.                 // be the user's first visit to this page.
  47.                 
  48.                 Response.Write("Welcome to this page.");
  49.             }
  50.             else
  51.             {
  52.                 // Remind the user of the last time she/he
  53.                 // visited this page.
  54.  
  55.                 Response.Write("You last visited this page on " + LastVisitCookie);
  56.             }        
  57.         %>
  58.  
  59.         <p><A href="Cookie_JScript.asp">Revisit This Page</A>
  60.  
  61.     </BODY>
  62. </HTML>
  63.