|
| |||||||
![]() | Welcome to iWEBTOOL Talk, where you talk about
webmaster-related stuff.
1 Register
2 Browse the board
3 Discuss whatever may interest you! | |||||||||||||
![]() |
| | Thread Tools | Search this Thread | Display Modes |
| | #1 |
| Newcomer Join Date: Jun 2007
Posts: 6
![]() | //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); } } } } http://www.hanusoftware.com
__________________ http://www.hanusoftware.com |
| |
|
| |||||||
| | #2 |
| Newcomer Join Date: Aug 2007
Posts: 18
![]() | Another simple example for Classic ASP: <% Dim user_name 'To Store Response.Cookies("user")="John" 'To Retrieve user_name=Request.Cookies("user") 'To Display the Value Response.Write(user_name) %> |
| |
(Threads which have no activity for more than 30 days are automatically closed.) |
| Quick Reply | ||
|
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Filter Data | superb | Search Engine Optimization (SEO) | 4 | 02-13-2007 02:26 AM |
| usage data page | kenni | Yahoo APIs | 1 | 11-27-2006 06:13 AM |
| Sessions or Cookies? | Intripita-MH | PHP | 6 | 10-14-2006 06:32 PM |
| Big Daddy Data Center | AidenJ | 1 | 01-06-2006 09:08 PM | |