Page.User.Identity.Name is readonly.

I want to put the username in the following:
 if (!Page.IsPostBack)
            {
                UserDB.UsersDB user = new UserDB.UsersDB();
               
                SqlDataReader reader = user.GetUserInfo(Int32.Parse(Page.User.Identity.Name));
                Page.User.Identity.Name = Response.Cookies["UserName"].Value;
                while (reader.Read())
                {
                    lblUserName.Text = reader.GetString(1);
                    lblFirstName.Text = reader.GetString(2);
                    lblLastName.Text = reader.GetString(3);
                    lblZodiacSign.Text = reader.GetString(6);
                    lblAge.Text = reader.GetInt32(7).ToString();
                    lblGender.Text = (reader.GetInt32(8) == 0) ? "Male" : "Female";
                    lblDateOfBirth.Text = reader.GetDateTime(9).ToString("d");
                    lblLastOnline.Text = reader.GetDateTime(15).ToString();
                    lblLocation.Text =  reader.GetString(22).ToString() + ", " + GetCountryName(reader.GetString(19));


                }
            }
if (Page.IsValid == true)
        {
 
            // Attempt to Validate User Credentials using CustomersDB
            string sSessionID = this.Session.SessionID;
 
            UserDB.UsersDB user = new UserDB.UsersDB();
            UserDB.UserDetails myUser = user.Login(txtUserName.Text, txtPassword.Text, sSessionID);
 
            if (myUser != null)
            {
 
 
                // Cookie with User Name
                if (!chkRememberPassword.Checked)
                {
                    // Store the user's fullname in a cookie for personalization purposes
                    Response.Cookies["UserName"].Value = myUser.sUserName;
                }
                else
                {
                    // Persist the cookie also up until 12:00AM since
                    // we need to allow user to rec points for loggin in
                    Response.Cookies["UserName"].Value = myUser.sUserName;
                    Response.Cookies["UserName"].Expires = DateTime.Now + new TimeSpan(365, 0, 0, 0);
                }
 
                //FormsAuthentication.SetAuthCookie(myUser.userID.ToString(),false);
                FormsAuthentication.RedirectFromLoginPage(myUser.userID.ToString(), chkRememberPassword.Checked);
 
 
 
 
            }
--------------------------------------------------------------------
<LoggedInTemplate>
						Welcome,
						<asp:LoginName ID="MemberName" runat="server" />
						|
						<asp:LoginStatus ID="MemberLoginStatus" runat="server" />
					</LoggedInTemplate>
 
The userid comes up instead of the username.

Open in new window

mathieu_cuprykAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vs1784Commented:
Page.User.Identity.Name = Response.Cookies["UserName"].Value;

This is wrong.

If you want to set value of logged in user then set this

FormsAuthentication.SetAuthCookie(myUser.userID.ToString(),false);


Hope it helps.

Thanks
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mathieu_cuprykAuthor Commented:
Wat will happen if I get into this page? It requires the id/

                UserDB.UsersDB user = new UserDB.UsersDB();
               
                SqlDataReader reader = user.GetUserInfo(Int32.Parse(Page.User.Identity.Name));

                while (reader.Read())
0
mathieu_cuprykAuthor Commented:
This does not work it takes me back to login page instead of default.aspx
0
mathieu_cuprykAuthor Commented:
any other answers would be appreciated.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.