Displaying Source Code(s)
|
|
Reading and writing cookies
--------------------------------------------------------------------------------
Description : You cannot do much useful in the Internet world
without writing a cookie to the users browser. This code shows
you how to store a cookie and cookie value and then retrieve it
using the response and request object.
<%@ LANGUAGE="VBSCRIPT" %>
<%option Explicit
Response.Buffer = True
Dim strCookieName
Dim strCookieValue
' Get the values passed in by the other
' script
strCookieName = "MyOwnCookie"
strCookieValue = "23"
' set the domain of the cookie to your o
' wn domain
' so it doesn't get confused with
' cookies created for Microsoft.com for
' example.
Response.Cookies(strCookieName).Domain = ".MyDomain.com"
'set cookie value
Response.Cookies(strCookieName) = strCookieValue
'set cookie expiration date
'note:set this to yesterday (or earlier)
' and you can
'delete the cookie!
Response.Cookies(strCookieName).Expires = Date() + 1
%>
The cookie <%= strCookieName%> Is =
<%= Request.Cookies(strCookieName)
%>
|
|
|