Cookie Collection Basics

Source: Internet
Author: User
Tags array integer set time

Cookies, Sessions, and application objects are similar and are collections objects that are used to save data. But the biggest difference between cookies and other objects is that cookies store data on the client's disk, while application and session objects store the data on the server side. Differences in application, section, and cookie objects are shown in the following table:

Object Data Storage Location lifecycle

Application on the Server side of memory. Terminates when IIS shuts down.

The session is stored on the server side of memory. Terminate at set time or offline by user.

Cookies are stored on the client's disk in profile form. Can always exist or be terminated at the time set.

The Cookies object is not subordinate to the Page object, so the usage is different from the application and the Session object. The Cookies object belong to the request object and the response object, each cookie variable is managed by the Cookies object, its correct object class name is HttpCookie Collection. To store a cookie variable, pass the Response object's cookie collection and use the following syntax:

Response.Cookies (Name as String). value= "Information"

To retrieve the cookie, it is a collection of cookies from the request object and returns the specified cookie, and its use syntax looks like this:

Variable =request.cookies (Name as String). Value

The commonly used properties of Cookies are shown in the following table:

Attribute Description Type

All returns all the cookie variables to an array. HttpCookie ()

AllKeys

Returns the names of all cookie variables into an array of string patterns.

String ()

Count returns the number of cookie variables. Integer

Item

Returns the contents of the cookie variable with the cookie variable name or index value.

1. Item (String) as

HttpCookie

2. Item (Index) as

HttpCookie

The common methods of Cookies are as shown in the following table:

Method Description Syntax

Add a new cookie variable into the cookies collection. ADD (ByVal cookie as HttpCookie)

Clear clears all the variables in the cookie set. Cookie Clear ()

Get

Returns a cookie with the cookie variable name or index value

The value of the variable.

1. Get (ByVal index as Integer) as

HttpCookie

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.