143 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			143 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 | |
| <HTML>
 | |
| <HEAD>
 | |
| <META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
 | |
| <TITLE>Cookies</TITLE>
 | |
| <SCRIPT LANGUAGE="JavaScript">
 | |
| <!--
 | |
| 	TempString = navigator.appVersion
 | |
| 	if (navigator.appName == "Microsoft Internet Explorer"){	
 | |
| // Check to see if browser is Microsoft
 | |
| 		if (TempString.indexOf ("4.") >= 0){
 | |
| // Check to see if it is IE 4
 | |
| 			document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
 | |
| 		}
 | |
| 		else {
 | |
| 			document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
 | |
| 		}
 | |
| 	}
 | |
| 	else if (navigator.appName == "Netscape") {						
 | |
| // Check to see if browser is Netscape
 | |
| 		document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
 | |
| 	}
 | |
| 	else
 | |
| 		document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
 | |
| //-->
 | |
| </script>
 | |
| <SCRIPT LANGUAGE="VBScript">
 | |
| <!--
 | |
| Sub Window_OnLoad()
 | |
|    Dim frmContents
 | |
|    On Error Resume Next
 | |
|    If Not Parent Is Nothing Then
 | |
|       Set frmContents = Parent.Contents
 | |
|       If Not frmContents Is Nothing Then
 | |
|             frmContents.Window.TOCSynch_Click
 | |
|       End If
 | |
|    End If
 | |
| End Sub
 | |
| //--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
 | |
| <META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
 | |
| <META NAME="MS.LOCALE" CONTENT="EN-US">
 | |
| <META NAME="MS-IT-LOC" Content="Internet Information Services"> 
 | |
| </HEAD>
 | |
| 
 | |
| <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
 | |
| 
 | |
| <H4><A NAME="_cookies_request"></A><SUP></SUP>Cookies</H4>
 | |
| 
 | |
| <P>The <B>Cookies </B>collection enables you to retrieve the values of the cookies sent in an HTTP request.</P>
 | |
| 
 | |
| <H6>Syntax</H6>
 | |
| 
 | |
| <P><B>Request.Cookies(</B><I>cookie</I><B>)</B>[<B>(</B><I>key</I><B>)</B>|<B>.</B><I>attribute</I>] </P>
 | |
| 
 | |
| <P> </P>
 | |
| 
 | |
| <H6>Parameters</H6>
 | |
| 
 | |
| <DL>
 | |
| <DT><I>cookie</I></DT>
 | |
| 
 | |
| <DD>Specifies the cookie whose value should be retrieved.<BR>
 | |
| </DD>
 | |
| 
 | |
| <DT><I>key</I></DT>
 | |
| 
 | |
| <DD>An optional parameter used to retrieve subkey values from cookie dictionaries.<BR>
 | |
| </DD>
 | |
| 
 | |
| <DT><I>attribute</I></DT>
 | |
| 
 | |
| <DD>Specifies information about the cookie itself. The attribute parameter can be the following.
 | |
| 
 | |
| <TABLE border=0 cellpadding=5 cols=2 frame=box rules=all>
 | |
| 
 | |
| <TR VALIGN="top">
 | |
| <TD class=blue width=25%><B>Name</B></TD>
 | |
| <TD class=blue width=75%><B>Description</B></TD>
 | |
| </TR>
 | |
| 
 | |
| <TR VALIGN="top">
 | |
| <TD width=25%><B>HasKeys</B></TD>
 | |
| <TD width=75%>Read-only. Specifies whether the cookie contains keys.</TD>
 | |
| </TR>
 | |
| </TABLE><BR>
 | |
| 
 | |
| </DD>
 | |
| </DL>
 | |
| 
 | |
| <H6>Remarks</H6>
 | |
| 
 | |
| <P>You can access the subkeys of a cookie dictionary by including a value for <I>key</I>. If a cookie dictionary is accessed without specifying <I>key</I>, all of the keys are returned as a single query string. For example, if <B>MyCookie</B><CODE> </CODE>has two keys, First<I> </I>and Second, and you do not specify either of these keys in a call to <B>Request.Cookies</B>, the following string is returned.</P>
 | |
| 
 | |
| <PRE><CODE>First=firstkeyvalue&Second=secondkeyvalue
 | |
|  </CODE></PRE>
 | |
| 
 | |
| <P>If two cookies with the same name are sent by the client browser, <B>Request.Cookies </B>returns the one with the deeper path structure. For example, if two cookies had the same name but one had a path attribute of /www/ and the other of /www/home/, the client browser would send both cookies to the /www/home/ directory, but <B>Request.Cookies</B> would only return the second cookie.</P>
 | |
| 
 | |
| <P>To determine whether a cookie is a cookie dictionary (whether the cookie has keys), use the following script.</P>
 | |
| 
 | |
| <PRE><CODE><%= Request.Cookies("myCookie").HasKeys %> 
 | |
|  </CODE></PRE>
 | |
| 
 | |
| <P>If <CODE>myCookie</CODE> is a cookie dictionary, the preceding value evaluates to TRUE. Otherwise, it evaluates to FALSE.</P>
 | |
| 
 | |
| <P>You can iterate through all the cookies in the <B>Cookie </B>collection, or all the keys in a cookie. However, iterating through keys on a cookie that does not have keys will not produce any output. You can avoid this situation by first checking to see whether a cookie has keys by using the <B>.HasKeys</B> syntax. This is demonstrated in the following example:</P>
 | |
| 
 | |
| <PRE><CODE><%
 | |
|     For Each strKey In Request.Cookies
 | |
|       Response.Write strKey & " = " & Request.Cookies(strKey) & "<BR>"
 | |
|       If Request.Cookies(strKey).HasKeys Then
 | |
|         For Each strSubKey In Request.Cookies(strKey)
 | |
|           Response.Write "->" & strKey & "(" & strSubKey & ") = " & _
 | |
|             Request.Cookies(strKey)(strSubKey) & "<BR>"
 | |
|         Next
 | |
|       End If
 | |
|     Next
 | |
| %>
 | |
| 
 | |
|  </CODE></PRE>
 | |
| 
 | |
| <H6>Example</H6>
 | |
| 
 | |
| <P>The following example prints the value of myCookie in a Web page.</P>
 | |
| 
 | |
| <PRE><CODE>Here is the value of the cookie named myCookie: 
 | |
| <%= Request.Cookies("myCookie") %> 
 | |
|  </CODE></PRE>
 | |
| 
 | |
| <P><span class=le><B>Note   </B></span>Cookies are described in detail in the HTTP state management specification, which is available at<span class=le> the </span><a href="http://www.microsoft.com/isapi/redir.dll?prd=external&sbp=W3org&pver=1.0&ar=specs" target=_blank><b><span class=le>World Wide Web Consortium Web site</span></b></a><span class=le>.</span></P>
 | |
| 
 | |
| <H6>Applies To</H6>
 | |
| 
 | |
| <P><A HREF="/iishelp/iis/htm/asp/vbob5ulw.htm"><B>Request</B> Object</A></P>
 | |
| 
 | |
| <H6>See Also</H6>
 | |
| 
 | |
| <P><A HREF="/iishelp/iis/htm/asp/vbob8q5h.htm"><B>ClientCertificate</B></A>, <A HREF="/iishelp/iis/htm/asp/vbob4fl9.htm"><B>Form</B></A>, <A HREF="/iishelp/iis/htm/asp/vbob53hj.htm"><B>QueryString</B></A>, <A HREF="/iishelp/iis/htm/asp/vbob5vsj.htm"><B>ServerVariables</B></A></P>
 | |
| <hr class="iis" size="1">
 | |
| <p align="center"><em><a href="../../../common/colegal.htm">© 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
 | |
| </BODY>
 | |
| </HTML>
 |