How can I display all of the cookies/cookie values for a user through a Web page? [Print this FAQ]
Answer:
All of the cookies and their values for a particular user are stored in the Cookies collection of the Request object. These can easily be cycled through using a For Each ... Next script. Such a script is shown below, and was submitted by Ed A. (armelino@yahoo.com):
<html> <body> <font face="ariel, helvetica" size="3"> Here are the active session Cookies with Keys: </font> <table border="0" cellspacing="0" cellpadding="0"> <% Dim Cookie, Key, vCount vCount = 0
For Each Cookie in Request.Cookies %> <tr> <td colspan="2"> <font face="ariel, helvetica" size="3"> The Name of the Cookie is: <font color=#FF0000> <%=Cookie%></font><br> </font> </td> </tr><%
If Request.Cookies(Cookie).HasKeys Then For Each Key in Request.Cookies(Cookie)%> <tr> <td> <font face="ariel, helvetica" size="2"> <%=Cookie%> (<%=vCount%>) is called: <%=Key%> </font> </td> <td> <font face="ariel, helvetica" size="2"> <%=Cookie%> (<%=Key%>) = <%=Request.Cookies(Cookie)(Key)%> </font> </td> </tr>
<% vCount = vCount + 1 Next Else %> <tr> <td colspan="2"> <font face="ariel, helvetica" size="2"> No Keys in this cookie. <br> </font> </td> </tr> <% End If
Response.Write "<br><br>" vCount = 0 Next %> </table> </body> </html>
FAQ posted by Scott Mitchell at
10/15/2000 2:49:00 AM to the
Cookies category.
This FAQ has been viewed 59,803 times.
Do you have a FAQ you'd like to suggest?
Suggestions? Comments? If so, send it in!
Also, if you'd like to be a FAQ Admin (creating/editing FAQs),
let me know! If you are looking for other FAQs, be
sure to check out the 4Guys
FAQ and Commonly Asked Messageboard Questions!