| Custom Shopping Cart & eCommerce Merchant Account Integration services |
|
|
● |
|
![]() |
|
|
| You are here: Home · Dev Zone · ASP Cookies Tutorial |
|
Cookies in ASPA cookie is a small piece of information that a server can store in a Web browser. Each time the browser requests a page from the server it sends the relevant cookies too. ASP allows you to create and retrieve cookies easily. Creating a CookieCookies are created using Example Cookie Creation<%
Response.Cookies("username") = "earthskater"
Response.Cookies("username").Expires = Date + 365
%>
In the example above a cookie named Retrieving CookiesTo retrieve cookies we use Example Cookie Retrieval<%
username = Request.Cookies("username")
response.write("Username: " & username)
%>
This code retrieves the value of the cookie named Cookies with Multiple ValuesCookies can also contain multiple values, using something called keys. Take a look at this example. <%
Response.Cookies("user")("realname") = "John Doe"
Response.Cookies("user")("username") = "johnny55"
Response.Cookies("user")("age") = "55"
%>
This is fairly straightforward to understand. Retrieving the cookies is very simple too. <%
realname = Response.Cookies("user")("realname")
username = Response.Cookies("user")("username")
age = Response.Cookies("user")("age")
%>
Listing All CookiesYou may want to list all the cookies available in a particular request. Here is how to do it. <%
Dim x,y
For Each x in Request.Cookies
Response.Write("<p>")
If Request.Cookies(x).HasKeys Then
For Each y in Request.Cookies(x)
Response.Write(x & ":" & y & "=" & Request.Cookies(x)(y))
Response.Write("<br />")
Next
Else
Response.Write(x & "=" & Request.Cookies(x) & "<br />")
End If
Response.Write "</p>"
Next
%>
The The Cookies CollectionHere is a quick reference table of properties that you can set on cookies in ASP.
|
|
|
||||||
|
Home | eCommerce Shopping Cart | Affiliate Software | Website Analytics | eCommerce Merchant Accounts | Merchant Account Integration |
||||||
|
|
||||||
|
Help & Support | Contact | Request a Quote | Affiliates | Developer Articles | Marketing Articles | Blog | Policies | Site Map |
||||||
|
|
||||||
|