ASP 101 - Active Server Pages 101 - Web03
The Place ASP Developers Go!



Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates
ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash





ASP Source Code:
<%
' This is always a good idea when dealing with
' cookies!  Especially cookies and a redirect!
Response.Buffer = True
' This script handles both the adding and deleting of cookies
Dim strCookieName  ' The name of the cookie we're processing
Dim strCookieValue ' The value to be assigned to it
' Get the values passed in by the other script
strCookieName  = CStr(Request.QueryString("name"))
strCookieValue = CStr(Request.QueryString("value"))
' If no name is passed in then we don't do anything
If strCookieName <> "" Then
	' This is so the cookie will apply to any ASP 101
	' server not just the one that set it.
	'Response.Cookies(strCookieName).Domain = ".asp101.com"
	' I removed the above line because people were having trouble
	' getting the script to run on their servers!
	' Set the value of the cookie.  You need to set the
	' value to something even if you're trying to delete
	' it! If you set it to "" then it won't work! If the
	' value passed in is nothing then we know to expire
	' the cookie by setting it's expiration date to
	' yesterday, otherwise we set it to expire tomorrow.
	If strCookieValue <> "" Then
		Response.Cookies(strCookieName) = strCookieValue
		Response.Cookies(strCookieName).Expires = Date() + 1
	Else
		Response.Cookies(strCookieName) = "must be something!"
		Response.Cookies(strCookieName).Expires = Date() - 1
	End If
End If
' Bounce users back to the display page
Response.Redirect("cookie.asp") 
%>

Back the the Sample Output

Back to the Sample Index


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers