SEO | Website Design | Web development
Community forum for Expert Assistance!
SEO Forum - Web Design : Web Hosting : Web Development : SEO Forum » ASP programming
»how to store and retrieve data from cookies
Reply to topic Page 1 of 1
how to store and retrieve data from cookies
Author Message
Reply with quote
Post how to store and retrieve data from cookies 
//This example shows that how to store and retrieve data from cookies.
// http://www.hanusoftware.com

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!IsPostBack)
{
if(Request.Cookies["UserCook"] != null)
{
chkRemember.Checked = true;
HttpCookie cook = Request.Cookies["UserCook"];
txtUserName.Text = cook["UserName"].ToString();

}
}
}
private void btnSubmit_Click(object sender, System.EventArgs e)
{
try
{
if(chkRemember.Checked == true)
{
if(Request.Browser.Cookies == true)
{
HttpCookie loginCook = new HttpCookie("UserCook");
loginCook["UserName"] = txtUserName.Text.Trim();
loginCook.Expires = DateTime.MaxValue;
Response.Cookies.Add(loginCook);
}
else
{
lblErr.Text = "Please enable your cookies in Internet
option in Explorer.";
}
}
if(txtUserName.Text.Trim() == "developer" &&
txtPwd.Text.Trim() == "developer")
{
Session["UserId"] = txtUserName.Text.Trim();
Response.Redirect("Querystring.aspx?Usertype=Web Developer");
}
else if(txtUserName.Text.Trim()=="admin" && txtPwd.Text.Trim()== "admin")
{
Session["UserId"] = txtUserName.Text.Trim();
string str = Server.UrlEncode("Administrator+");

Response.Redirect("Querystring.aspx?UserType="+str);
}
else
{
lblErr.Text = "Invalid user id and password.";
}
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
}
}
}



[url=http://www.hanusoftware.com]Software Development India[/url]

Display posts from previous:
SEO Forum - Web Design : Web Hosting : Web Development : SEO Forum » ASP programming
»how to store and retrieve data from cookies


 
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  


SEO Services |Search Engine Optimization |SEO Forum | Web Design | Web Development | Office Cleaning Atlanta |SEO Marketing forum |Website Design forum |Web Hosting discussion |SEO Marketing |Promotional Products Grant writing workshops | SEO Marketing | Mahjong Games | Promotional Items | CLEP Exam | New homes Dallas | Paintball | New homes Houston | Paintball | Top social networking websites | Caribbean Villas Rental | Build your website Free |Mahjong| Grant Writing Seminars | Dvla Number Plates