1

更具体地说,铬。在 Firefox、IE 或 Opera中不会发生以下情况。

当我登录时,我收到提示,询问我是否要允许浏览器存储用户的用户名和密码。但是,无论我从选项中选择什么(是的,本网站从不),如果我退出并重新登录,我都会得到相同的提示。

我的登录表单的 HTML 如下:

    <form id="def_mainForm" runat="server">
<div id="loginContainer">
    <asp:Panel ID="pnlLog" runat="server" DefaultButton="btnLogSubmit">
        <div id="loginFormContainer">
            <div class="logGroup">
                <div class="logLabel boldFont">
                    Email / Username
                 </div>
                 <asp:TextBox ID="username" runat="server" CssClass="loginBoxes" ToolTip="Enter your email address or username here" />
             </div>
             <div class="logGroup">
                 <div class="logLabel boldFont">
                     Password
                 </div>
                 <asp:TextBox ID="password" runat="server" TextMode="Password" CssClass="loginBoxes" ToolTip="Enter your password here" />
                  <a href="respass.aspx" class="logLabel">Forgot your password?</a>
             </div>
             <div id="logButtonHolder">
                 <asp:Button ID="btnLogSubmit" runat="server" Text="Log in" CssClass="defButton" />
             </div>
        </div>
    </asp:Panel>
</div>

这个的代码隐藏是这样的:

    void btnLogSubmit_Click(object sender, EventArgs e)
{
    this.validateUser(this.username.Text, this.password.Text, false);
}

void btn_gmb_OK_Click(object sender, EventArgs e)
{

}

private void validateUser(string email, string password, bool remember)
{
    Common.Validator validator = new Common.Validator(email, password);
    string response = "";
    int userId = -1;
    int personId = -1;
    bool valid = validator.Validate(out response, ref userId, ref personId);

    if (valid)
    {
        this.Session["gs_sessionId"] =  this.Session.SessionID;
        this.Session["gs_userId"] = userId;
        this.Session.Timeout = 60;
        HttpCookie remCookie = new HttpCookie("gsc_sessionId", this.Session["gs_sessionId"].ToString());
        remCookie.HttpOnly = true;

        if (remember)
            remCookie.Expires = DateTime.MaxValue;
        else
            remCookie.Expires = DateTime.Now.AddMinutes(60);

        Response.Cookies.Add(remCookie);

        gsWs.AddUserLogin(wsPass, userId, Request.UserHostAddress);
        this.Session["gs_person"] = gsWs.GetPersonByUserId(wsPass, userId).OuterXml;
        Response.Redirect("home.aspx");
    }
    else
    {

    }
}

我用谷歌搜索了这个问题,我只遇到希望使用“autocomplete=off”完全禁用此功能的人,添加它,我可以添加,仍然会导致相同的问题。

我错过了一些明显的东西吗?我做错了什么吗?您可以提供的任何帮助或建议将不胜感激。

编辑:

以下是检查 cookie 的代码:

    protected bool checkAlreadyLoggedIn()
{
    bool loggedIn = false;
    try
    {
        if ((Request.Cookies["gsc_sessionId"] != null) && (Request.Cookies["gsc_sessionId"].Value != ""))
        {
            this.Session["gs_sessionId"] = Request.Cookies["gsc_sessionId"].Value;
            loggedIn = true;
            Response.Redirect("home.aspx");
        }
        if (this.Session["gs_sessionId"] != null)
        {
            loggedIn = true;
            Response.Redirect("home.aspx");
        }
    }
    catch (Exception ex)
    {

    }
    return loggedIn;
}

protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        if (!this.IsPostBack)
            if (!(this.checkAlreadyLoggedIn()))
                this.logUserOut(false);

    }
    catch (Exception ex)
    {

    }
}

protected void logUserOut(bool redirect)
{
    if (this.Session["gs_sessionId"] != null)
    {
        this.Session["gs_sessionId"] = null;
        this.Session.Abandon();
        Response.Cookies["gsc_sessionId"].Expires = DateTime.MinValue;
        Response.Cookies["gsc_sessionId"].Value = "";
        if (redirect)
            Response.Redirect("Default.aspx");
    }
    else
        if (redirect)
            Response.Redirect("Default.aspx");
}
4

0 回答 0