I have created such a feature for a site that I designed. What I did is that when the user logs on initially, I check if the "Remember Me" checkbox is checked or not. If it is checked, then I set a cookie on the client computer with the value in the Username field. Then, next time they visit the site, I check to see if the cookie exists. If it does, then I fill the Username field with the value contained in the cookie. I did all this in JavaScript.
I used the following functions for it:
function GetCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}
This function is what I use to get the value of the cookie. The GetCookie function returns the value that is stored in the cookie that is called name.
Then, I use the following function:
if (GetCookie('GSUserLogin') != null)
{
document.getElementById("txtUserName").value = GetCookie('GSUserLogin');
document.getElementById("txtPassword").focus();
}
else
{
document.getElementById("txtUserName").focus();
}
if (GetCookie("GSUserLogin") != "")
{
document.getElementById("chkRememberUserID").checked = true;
}
Here, I check to see if the cookie exists. If it does, then fill txtUserName with the value of the cookie and set the focus to the txtPassword field, otherwise, set the focus to txtUserName.
I also set a cookie on the client's computer if the "Remember Me" checkbox is checked, since it is possible that the visitor may not ever want to remember their username.
I hope this helps.