Hi!
I've been implementing forms based authentication in a web project. It works
pretty good. When I log on by clicking the "login" button the following code
is executed:
if (ValidateUser(strUserName,txtUserPass.Value))
{
DBFunctions Commoncode;
Commoncode = new DBFunctions();
string strAdminRights;
Session["UserID"] = Commoncode.GetDBValue ("SELECT userID FROM Users WHERE
uname = '" + strUserName + "'", "Users", "userID");
strAdminRights = Commoncode.GetDBValue ("SELECT userAdminRights FROM Users
WHERE uname = '" + strUserName + "'", "Users", "userAdminRights");
if (strAdminRights == "1")
{
Session["AdminRights"] = "true";
}
else
{
Session["AdminRights"] = "false";
}
FormsAuthentication.RedirectFromLoginPage(strUserN ame,
chkPersistCookie.Checked);
}
This as you can see sets a couple of session variables. The problem is that
I've made it possible to use a persistent cookie so that users don't have to
key in their credentials everytime they log in.When the cookie is used users
are granted access immediately and the code above is not used and therefore
the session variables are not initialized.
Does anyone know how to solve this?
Thanks in advance
Morten