Click here to Skip to main content
15,915,093 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
we decler varibel

a="1234",
b="1234"

later user need to change b value how it is possibel whit out using db

What I have tried:

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Details;




namespace loginproject
{
    

    public partial class login : System.Web.UI.Page
    {
     
       
        protected void Page_Load(object sender, EventArgs e)
        {
            
            Session["username"] = Detail.username;
            Session["Password"] = Detail._password;
            if (!IsPostBack)
              
            {

                if (Request.Cookies["username"] != null)

                    txt_email.Text = Request.Cookies["username"].Value;

                if (Request.Cookies["Pass"] != null)

                    txt_pwd.Attributes.Add("value", Request.Cookies["Pass"].Value);
                if (Request.Cookies["username"] != null && Request.Cookies["Pass"] != null)
                    rember.Checked = true;
            }
          


        }

        protected void btn_submit_Click(object sender, EventArgs e)
        {
          


            if (txt_email.Text == Session["username"].ToString() && txt_pwd.Text == Session["Password"].ToString())
            {
                if (rember.Checked == true)
                {
                    Response.Cookies["username"].Value = txt_email.Text;
                    Response.Cookies["Pass"].Value = txt_pwd.Text;
                    Response.Cookies["username"].Expires = DateTime.Now.AddDays(15);
                    Response.Cookies["Pass"].Expires = DateTime.Now.AddDays(15);
                }
                else

                {

                    Response.Cookies["username"].Expires = DateTime.Now.AddDays(-1);

                    Response.Cookies["Pass"].Expires = DateTime.Now.AddDays(-1);

                }
                Response.Redirect("home.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Invalid Username Or Password')</script>");
            }

        }
    }
}
Posted
Updated 5-Apr-18 19:54pm
Comments
F-ES Sitecore 6-Apr-18 4:24am    
BTW cookies are not secure, don't store people's passwords in cookies.

1 solution

Use a cookie, or use the session - depending on how "permanent" you want the change to be. This assumes that you want the change to affect one user; if you want one user to affect many, then you need to use some form of storage that many users can change and access - and the best medium for that is a database server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900