asp.net application cookies Sessions Server built-in objects (1/4)

Source: Internet
Author: User
Tags datetime sessions

ASP tutorials. NET application cookies sessions server built objects

Many objects are built into the ASP.net tutorial, including application, response, request, cookies, sessions, cache, server, and viewstate. Through these objects, you can provide some essential features of the site, such as the absolute path to the file, the number of people online, the total number of visitors to the site, online store shopping box.
The cookie object uses the key/value pair method to record the data, and the statement mycookie.expires=datetime.now.addhours (1) specifies when the data in the cookie expires, which is 1 hours after the expiration. If you do not specify an expiration time, exiting the Web page immediately expires.

Write

The value of the cookie is as follows:

HttpCookie mycookie=new HttpCookie ("userinfo");

Mycookie.value=2.tostring ();

Mycookie.expires=datetime.now.addhours (1); Response.Cookies.Add (MyCookie);

The value of the cookie is removed by the following methods:

HttpCookie mycookie=request.cookies["UserInfo"];

int num=convert.toint16 (MyCookie.

Value

);

Home 1 2 3 4 last page
Related Article

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.