ASP. Initial knowledge of cookies

Source: Internet
Author: User

1.ASP. NET use of cookies

1. Create a new cookie

HttpCookie cookietest =newhttpcookie ("ID","234"); // One Step RESPONSE.COOKIES.ADD (CookieTest); // Enter the cookie file you created into the browser side

It can also be used in a response.cookies manner, but cookies created in this way are not easy to operate and can only be used when creating cookies
    1.   

      response.cookies["UserName"]. Value= "Chinajiyong";

2. New multi-valued cookie
       H Ttpcookie cookietest =newhttpcookie (  WONDERDCH   ); cookietest.values[   username   "]="  dch   ;cookietest.values[ "  password  ]="  12123   ; RESPONSE.COOKIES.ADD (cookietest);  

       

Multi-valued cookie viewing effect 3. Read the data in the cookie
    1. HttpCookie cookietest =newhttpcookie ("ID","234"); // create an instance of the cookie. Response.Cookies.Add (cookietest); // Enter the cookie file you created into the browser side Response.Write (request.cookies["ID"). Value); // read the value stored in the cookie file

The expiration date setting of the 4.Cookie file
  1. HttpCookie cookietest =newhttpcookie ("ID","234"); // create an instance of the cookie. cookietest.expires=datetime.now.addminutes (5); // set the expiration time of the cookie, expires after 5 minutes, automatically clears the file RESPONSE.COOKIES.ADD (CookieTest); // Enter the cookie file you created into the browser side Response.Write (request.cookies["ID"). Value); // read the value stored in the cookie file

5. Manually destroying cookies
  1. HttpCookie CookieTest =newhttpcookie ("ID","234");//create an instance of the cookie. Cookietest.expires=datetime.now.addminutes (5);//set the expiration time of the cookie, expires after 5 minutes, automatically clears the fileRESPONSE.COOKIES.ADD (CookieTest);//Enter the cookie file you created into the browser sideResponse.Write (request.cookies["ID"]. Value);//read the value stored in the cookie fileCookietest.expires=datetime.now.addminutes (-5);//Just give cookieexpires a negative time to manually destroy cookies

6.Chrome Browser View and edit Cookies widget Editthiscookie

: HTTP://WWW.CHROMEIN.COM/PUBLIC/CRX/FNGMHNNPILHPLAEEDIFHCCCEOMCLGFBG/CHROMEIN.COM_EXT_11241.CRX

2. View the cookies saved in the 360 speed browser

1. Access Options-Advanced settings-Network Content-Content settings


2. View all cookies and website data (may be a small card)


3. Follow the site search to find the cookie that you set earlier WONDERDCH



From for notes (Wiz)



ASP. Initial knowledge of cookies

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.