Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
First, we will give a brief introduction to the Cookie to illustrate how to use ASP to maintain the cookie.
Cookie is a small file stored in the client computer, which means that every time a user visits your site, you can secretly put a file containing the relevant information on its hard disk. This file contains almost any information you want to set, including user information and site status. In this case, there is a potential danger: The information may be read by hackers. To prevent this problem, a valid method is that the cookie can only be accessed by the domain where it is created. For example, ytu.edu.cn can only access cookies created by ytu.edu.cn. Generally speaking, there is no problem. But what if two different sites in two different domains need to share the user information stored in cookies? Of course, you can choose to copy user mail. However, what if you want users to register only on one site and become registered users on another site in the East? Or, do two sites share a user database and require automatic user login? At this time, sharing cookies across domains is the best solution.
Here, let's take a look at some ASP cookie processing code for reference later.
Response. Cookies ("MyCookie"). Expires = Date + 365
Response. Cookies ("MyCookle"). Domain = "mydomaln.com"
Response. Cookies ("MyCookle") ("Username") = strUsername
Response. Cookies ("MyCookle") ("Password") = strPassword
The preceding code creates a cookie and sets attributes for the cookie: Domain, Expiration Time, and other values stored in the cookie. Here, strUsename and strPassword are the variables set in the previous place. Then, read in the cookie using the following statement.
DatExpDate = Request. Cookies ("MyCookie ")
StrDomaln = Request. Cookies ("MyCookle"). Domain
StrUsername = Request. Cookies ("MyCookle") ("Username ")
StrPassword = Request. Cookies ("MyCookie") ("Password ")
For more information, see ASP.
The key to sharing cookies is redirection. The general process is as follows:
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.