Important alert: (current site time 10/24/2014 4:08:16 PM EDT)
 

VB icon

Show all cookies (multi-value cookie arrays and single-value cookies)

Email
Submitted on: 3/19/2001 11:33:58 AM
By: Chris Blessing  
Level: Intermediate
User Rating: By 2 Users
Compatibility: ASP (Active Server Pages)
Views: 16566
(About the author)
 
     This code displays all cookies that are on your computer from a specific domain. That domain is whatever site you view the .asp page through. So if you're setting a cookie on yoursite.yourhost.com, and you wanna see exactly what's going on, simply upload this page to your site and hit it up via a web browser, and bling bling you got all the info! Great for debugging cookie problems, hence the reason I developed it. This code is 100% mine, by the way.

 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
' for :Show all cookies (multi-value cookie arrays and single-value cookies)
'**************************************
(c) 2001, Chris Blessing.
If you choose to use or modify this code, please let me know via email. webguy@mail.rit.edu
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Show all cookies (multi-value cookie arrays and single-value cookies)
' Description:This code displays all cookies that are on your computer from a specific domain. That domain is whatever site you view the .asp page through. So if you're setting a cookie on yoursite.yourhost.com, and you wanna see exactly what's going on, simply upload this page to your site and hit it up via a web browser, and bling bling you got all the info!
Great for debugging cookie problems, hence the reason I developed it. This code is 100% mine, by the way.
' By: Chris Blessing
'
' Returns:Cookies, cookie entities (if any) and matching values.
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=6539&lngWId=4'for details.'**************************************

<HTML>
<HEAD>
<TITLE>Cookie Viewer</TITLE>
</HEAD>
<STYLE TYPE="text/css">
	.title{
		font-family: Verdana, Arial;
		color: #000000;
		font-size: 18pt;
		font-weight: bold;
	}
	.cookieName{
		font-family: Verdana, Arial;
		color: #8B0000;
		font-size: 10pt;
		font-weight: bold;
	}
	.cookieType{
		font-family: Verdana, Arial;
		color: #000000;
		font-size: 14pt;
	}
	.cookieItem{
		font-family: Verdana, Arial;
		color: #00008B;
		font-size: 10pt;
		font-weight: bold;
	}
	.cookieItemValue, .cookieValue{
		font-family: Verdana, Arial;
		color: #000000;
		font-size: 10pt;
	}
	.footer{
		font-family: Verdana, Arial;
		font-size: 7pt;
	}
	BODY{
		font-family: Verdana, Arial;
		font-size: 10pt;
	}
</STYLE>
<BODY>
<CENTER>
<SPAN CLASS="title">Cookie Viewer</SPAN>
</FONT>
<TABLE CELLPADDING=4 CELLSPACING=0 BORDER=0>
<TR><TD><HR SIZE=1></TD></TR>
<TR><TD CLASS="cookieType">
	Multi-value cookies (cookie arrays)
</TD></TR>
<TR><TD>
	<UL>
	<% for each cookie in Request.Cookies 
	' we want to loop through every cookie in the Request.Cookies collection
		if Request.Cookies(cookie).Count <> 0 then %>
		<!-- this means it's a multivalue cookie -->		
			<TABLE CELLPADDING=2 CELLSPACING=0 BORDER=0>
			<TR><TD CLASS="cookieName">
			<!-- write out the cookie name -->
				<% = cookie %>
			</TD></TR>
			<TR><TD>
				<UL>
				<% for each item in Request.Cookies(cookie) %>	
				<!-- loop through each entity of the cookie, writing it out and writing out it's corresponding value -->
					<LI><SPAN CLASS="cookieItem"><% = item %></SPAN><SPAN CLASS="cookieValue"> = <% = Request.Cookies(cookie)(item) %></SPAN></LI>
				<% next %>	
				</UL>
			</TD></TR>
			</TABLE>
		<% end if
	next %>
</TD></TR>
<TR><TD>
	<SPAN CLASS="cookieType">Single-value cookies</SPAN>
</TD></TR>
<TR><TD>
	<UL>
	<% for each cookie in Request.Cookies
	' again, loop through all the cookies (yes we could have done this differently but I'm lazy)
		if Request.Cookies(cookie).Count = 0 then %>
		<!-- if we have a single-value cookie, write out the name + "=" + the value -->
			<LI><SPAN CLASS="cookieName"><% = cookie %></SPAN><SPAN CLASS="cookieValue"> = <% = Request.Cookies(cookie) %></SPAN></LI>
		<% end if
	next %>
</TD></TR>
<TR><TD><HR SIZE=1></TD></TR>
<TR><TD ALIGN="right" CLASS="footer">
	Written by Chris Blessing, <A HREF="mailto:webguy@mail.rit.edu">webguy@mail.rit.edu</A>
</TD></TR>
</TABLE>
</CENTER>
</BODY>
</HTML>


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.