ASP.net learning Purpose: Learn the session and use of cookies
In the various pages of the variable transmission and some record user login information to use session and cookies. Using cookies in asp.net is a bit more cumbersome than ASP, because we want to declare variables.
First look at the use of the session, basic and ASP almost
Write a session:
Let's take a look at the writing of the cookie:
DateTime Dt=datetime.now; Need to <% @Import namespace= "System"%>, to get the current time
HttpCookie mycookie=new HttpCookie ("logname");/declare new cookie variable
MyCookie. Value= "AA";//Assign Value
MyCookie. Expires=convert.todatetime (Dt+timespan.fromdays (1));/set expiration time of 1 days
RESPONSE.COOKIES.ADD (MYCOOKIE1);//write Cookie
Dim MyCookie As HttpCookie
mycookie=request.cookies["username"]
Dim String=mycookie. Value
To this "Ten days to learn asp.net" end, time is hasty, but also please forgive write incomplete, in fact, I just take you to get started, learn to rely on their own AH.
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.