Return to iWEBTOOL

Go Back   iWEBTOOL Talk > The Web and your Website > Web Development
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
Welcome to iWEBTOOL Talk, where you talk about webmaster-related stuff.
 
Discuss topics which interest you.
With over thousands of threads (topics), we're sure you'll find something that'll interest you.
Ask for help whenever you need it.
We have thousands of members who are available to help you if you need it.
It's absolutely FREE!

 1  Register           2  Browse the board           3  Discuss whatever may interest you!
 


Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 07-23-2007, 10:41 AM   #1
hanusoftware
Newcomer
 
hanusoftware's Avatar
 
Join Date: Jun 2007
Posts: 6
hanusoftware is on a distinguished road
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);
}
}
}
}




http://www.hanusoftware.com
__________________
http://www.hanusoftware.com
hanusoftware is offline  
 
This is an Ad Revenue Sharing forum Place your advert here
SEO Checklist
Get yourself better ranking with
our "Do-it-Yourself" SEO Checklist.
Click Here
Old 08-06-2007, 11:06 PM   #2
maher
Newcomer
 
maher's Avatar
 
Join Date: Aug 2007
Posts: 18
maher is on a distinguished road
Default Re: how to store and retrieve data from cookies

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)

%>
maher is offline  
 
This is an Ad Revenue Sharing forum Place your advert here
Webmaster Tools Webmaster Tools Click Here
Closed Thread

(Threads which have no activity for more than 30 days are automatically closed.)



Quick Reply
Message:

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Trackbacks are Off
Pingbacks are Off
Forum Jump

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 Google 1 01-06-2006 09:08 PM


All times are GMT. The time now is 03:25 AM.


Powered by vBulletin v3.6.7 © 2008, Jelsoft Enterprises Ltd. SEO by vBSEO © 2006, Crawlability, Inc.