Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8625577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:49:21+00:00 2026-06-12T07:49:21+00:00

I created a ‘Remember me’ option on an ASP site and the client said

  • 0

I created a ‘Remember me’ option on an ASP site and the client said they also wanted it to show the login name in the user field even after they press ‘logout’. It works as long as I don’t ever use a different login name again. Once I assign the value to the text box in the code behind, even if I manually type a new value the old value is what is used.

Example:

  1. I type a user/password (eg. User1), click ‘Remember me’ and login successfully.
  2. I log out and am redirected back to the login page. On the page_load event, it detects that there is a valid cookie with the user name stored (User1) and it reads the value and sets the text field.
  3. I change the login to something else (eg. User2) and it fails saying invalid user/password. Weird.
  4. I check the data and it is using the old text field (User1). I try another (eg. User3) and press login. It fails and when I check the Text property, it still says User1 even though on screen it says User3.

No matter what I do, it will not change once I set it in the codebehind file. It’s almost as if once the text field is set, it cannot be changed. This is not right, but I have no good explanation for it.

Here is the code in question:

Page load:

protected void Page_Load(object sender, EventArgs e)
{

    if (Request.ServerVariables["AUTH_USER"] != null && !Request.ServerVariables["AUTH_USER"].Equals(""))
    {
        login.Visible = false;
        logout.Visible = true;

        btnLogout.Text = "Logout " + Request.ServerVariables["AUTH_USER"];
    }
    else
    {
        login.Visible = true;
        logout.Visible = false;


        CheckLoginCookie();           
    }

}

Code to set the cookie:

private void SaveLoginCookie()
    {
        try
        {

            Response.Cookies["KYSUSR"].Value = txtLoginUsername.Text.Trim();
            Response.Cookies["KYSUSR"].Expires = DateTime.Today.AddMonths(6);

        }
        catch (Exception ex)
        {
            ExceptionHandling.SendErrorReport(this, ex);
        }
    }

Code to load the cookie:

   private void CheckLoginCookie()
    {
        try
        {            
            if (Request.Browser.Cookies)
            {
                if (Request.Cookies["KYSUSR"] != null && Request.Cookies["KSYFOR"] != null)
                {
                    // logged in as remember
                    if (Request.Cookies["KYSFOR"].Value == "R")
                        txtLoginUsername.Text = Request.Cookies["KYSUSR"].Value;
                    // once set here, the Text property never changes regardless of what is entered into it

                }                
            }            
        }
        catch (Exception ex)
        {
            ExceptionHandling.SendErrorReport(this, ex);
        }
    }

Code to do the login:

protected void btnLogin_Click(object sender, EventArgs e)
    {
        try
        {
            String user = txtLoginUsername.Text.Trim();

            if (chkSaveUser.Checked)
                SaveLoginCookie();
            else
            {
                // set cookie as expired so browser will clear it
                Response.Cookies["KYSUSR"].Expires = DateTime.Today.AddDays(-1);                
            }

            if (CheckLogin(user, txtLoginPassword.Text))
            {
                if (chkSaveUser.Checked)
                {                    
                    FormsAuthentication.SetAuthCookie(user, true);                    
                }

                FormsAuthentication.RedirectFromLoginPage(txtLoginUsername.Text.Trim(), false);
            }
        }
        catch (Exception ex)
        {
            ExceptionHandling.SendErrorReport(this, ex);            
        }
    }

Why would the Text property not change?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:49:22+00:00Added an answer on June 12, 2026 at 7:49 am

    The issue is that you don’t check if you are in a postback in your Page_Load method – which means even when the user puts something else in the txtLoginUsername Textbox it is overridden by CheckLoginCookie.

    protected void Page_Load(object sender, EventArgs e)
    {
    
        if (Request.ServerVariables["AUTH_USER"] != null
            && !Request.ServerVariables["AUTH_USER"].Equals(""))
        {
            login.Visible = false;
            logout.Visible = true;
    
            btnLogout.Text = "Logout " + Request.ServerVariables["AUTH_USER"];
        }
        else
        {
            login.Visible = true;
            logout.Visible = false;
    
            // Only check the login cookie if we are not dealing with a form submission.
            if (!Page.IsPostBack)
            {
                CheckLoginCookie();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Created new scaffold Users that has fields name & description All working as suppose
created a new IIS7 web site with Intergrated .net 4.0 app pool. URLs ending
Created BroadcastReceiver which displays application name and version number on install/ uninstall of any
Created .NET WCF service, tested it - works. Generated schemas from Data and service
Created Private Key & Self signed certficate in a Key Store keytool -genkey -alias
Created an OpenGraph action and object. Trying to submit my action. When I click
I created a python server on port 8000 using python -m SimpleHTTPServer . When
I created cookie with server side code (c#) and it was shown in chrome
I created a JButton which has an image set as an icon representing the
I created a following class within a namespace Global namespace Global { public static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.