Search

MY WEBGAME

WEBMASTERS

PROGRAMMERS

DIRECTORY

FORUM

SEARCH

Go Back   Web Development and SEO Forum India > Discuss Software Development > Dynamic Pages With ASP
User Name
Password


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-23-2007, 12:46 PM
hanusoftware hanusoftware is offline
Junior Member
 
Join Date: Jun 2007
Posts: 5
Default 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);
}
}
}
}





Software Development India
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 11:18 AM.
Contact Us | Archive | Top | Web Host India

Reseller Hosting Company - Dedicated Servers India - VPS Hosting - India Web Hosting - Linux Hosting - Windows Hosting - SEO India - Website Designing- Flash Development - Offshore Software Development India
Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

Our Network: Online Web Directory © 2006 - All Rights Reserved Powered By Brainpulse Technologies