Remember login username Function

Source: Internet
Author: User
// Enter the page for execution
// Read the saved cookie information httpcookie cookies = request. Cookies ["user_cookie"]; If (cookies! = NULL) {// If the cookie is not empty, read the username and password in the cookie and assign it to the text box at the front end. This. txt_username.text = Cookies ["username"]; // you can select the "Remember password" option here. This. usenamecheckbox. Checked = true ;}
// Run the login button
// Add cookie httpcookie cookie = new httpcookie ("user_cookie"); If (this. usenamecheckbox. checked) {// after all the authentication information is detected, if the user chooses to remember the password, the user name and password are written into the cookie and saved. Cookie. values. add ("username", this. txt_username.text.trim (); // set the cookie expiration time, which is the time of one week. After one week, the status is automatically cleared. Cookie. expires = system. datetime. Now. adddays (7.0); httpcontext. Current. response. Cookies. Add (cookie);} else {If (cookie! = NULL) {// if the user does not select to remember the password, immediately set the information in the cookie and keep the setting status expired immediately. Response. Cookies ["user_cookie"]. expires = datetime. Now ;}}

 

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.