0

I am using a Login Page which redirects to next page, but while redirecting I am getting remember password from browser side. How to disable it

the below code works in IE -8

but not working in Mozilla Firefox 30.0

and Chrome 35

<body>
<form id="form1" runat="server" method="post" autocomplete="off">
<div>
<table>
<tr>
<td>UserName</td>
<td><asp:TextBox ID="txtName" runat="server"/></td>
</tr>
<tr>
<td>Password</td>
<td><asp:TextBox ID="txtPwd" runat="server" TextMode="Password" autocomplete="off" /></td>
</tr>
 <tr>
 <td></td>
<td><asp:Button ID="btnSubmit" runat="server" Text="Submit" onclick="btnSubmit_Click" /></td>
</tr>
</table>
</div>
</form>
</body>

protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
    if (txtName.Text == "user" && txtPwd.Text == "pass")
    {
        txtPwd.Attributes.Add("autocomplete", "off");

        Response.Redirect("Register.aspx");
    }
    else
    {
    }
}
user3793207
  • 3
  • 1
  • 3
  • 2
    _The ability for websites to disable the password manager using `autocomplete = "off"` is being removed in Firefox 30_ See [Bug 956906](https://bugzilla.mozilla.org/show_bug.cgi?id=956906) Source [MDN: How to Turn Off Form Autocompletion](https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion) – Satpal Jul 01 '14 at 10:05
  • What about Chrome Version 35.0.1916.153 m – user3793207 Jul 01 '14 at 10:18
  • Sorry for this. I corrected my code. – s77s Jul 05 '14 at 17:40

2 Answers2

0

This is a browser specific feature and support has been discontinued by major browsers because of compatibility issues. Is autocomplete="off" compatible with all modern browsers?

Community
  • 1
  • 1
Fanie Reynders
  • 550
  • 3
  • 16
-1

Use:

<input onclick="request ();" type="button" value="Submit form" />

instead of any submit inputs and in function named: "request" call an "XMLHttpRequest" to your php file.
Example fiddle: JSFiddle.

Note: Fiddle outputs: "error: NOT FOUND", because there is no: "parse.php" in same dir. In your script you need change the name and parameters in "data" object.

Update:

<?php
    function decodeURIComponent ( $string ) { return rawurldecode ( $string ); }
    function encodeURIComponent ( $string ) { return ( decodeURIComponent ( $string ) === $string ? rawurlencode ( $string ) : $string ); }
    function isLogged ( $email, $password ) { return ( ( $email === encodeURIComponent ( "nobody@example.com" ) && $password === encodeURIComponent ( "reallyStrongPassword" ) ) ? true : false ); }
    foreach ( $_POST as $key => $value ) { $params [ encodeURIComponent ( $key ) ] = encodeURIComponent ( $value ); }
    // added encode checking and change API to JavaScript like
    // better security ( if JavaScript was modified )
    $count = count ( $_POST );
    if ( $count === 2 && isset ( $params [ "email" ] ) && isset ( $params [ "password" ] ) ) // security checks
    {
        $email = $params [ "email" ];
        $password = $params [ "password" ];
        /* here I check $email and $password with their hashes in MySQL file */
        $good = isLogged ( $email, $password );
        if ( $good ) { echo "<h1>Sucessfull logged in !</h1>"; }
        else { echo "<h1>Bad e-mail or password or not already registered !"; }
    }
    else { exit ( "Security critical error !" ); }
?>

Note: This is only an example code ...
Note: encodeURIComponent is really important in security cases.

Updated fiddle: JSFiddle

s77s
  • 176
  • 1
  • 1
  • 11
  • Could you pls share the parse.php page.. It is not working If I use my parse.php – user3793207 Jul 02 '14 at 03:47
  • I am getting error like this Parse error: syntax error, unexpected T_VAR in D:\wamp\www\example\parse.php on line 14 . I am new to PHP, My coding is C#.Net – user3793207 Jul 05 '14 at 05:05