How to send cookies to the client - preCharge Forums
It shows that you are unregistered. Please register with us by clicking Here
preCharge Forums


Nav Green LeftNav Right
preCharge Forums > Website Design & Development > Programming > .NET » How to send cookies to the client


Reply
Tcat Right
 
LinkBack Thread Tools Display Modes Tcat Right
Old 07-14-2006   #1 (permalink)
Tom Tom
Junior Member
 
Join Date: Jul 2006
Age: 47
Posts: 25
Default How to send cookies to the client

Cookies are little pieces of data stored on the client. With each Web request the cookies are sent back to the server and accessible from ASP.NET code, which allows you to perform tasks such as site personalization.(IIS actually use cookies to help manage sessions.) For example, the following lines of code send a Zipcode cookie back to the user:

Dim ckZip As new HttpCookie("Zipcode")
ckZip.Value = "28138"
ckZip.Expires = DateTime.Now.AddDays(30)
Response.Cookies.Add(ckZip)

When the user access the site again, the Zipcode cookie will be sent to the server, allowing it to display the weather or other ZIP Code-related information automatically. The Expires property of the cookie instructs the browser to throw it away after 30 days.

If you are curious how and where cookies are stored, look in the Temporary Internet Files folder. To view these files from Internet Explorer, choose Internet Option from the tool menu and click View Files. Drag one of the cookie files (begins with the word cookie) to the desktop and then open it in a text editor.

Because cookies are stored as plain text, I would recommend the following precautions when using cookies to keep track of a user's identity.

Use a random number (that is a GUID)rather then any actual key value from the database.

If your Web site has a list of users, do not display their random number in URL's.

Without taking the previous precautions, a user could edit his cookie file and impersonate another user.
Tom Tom is offline   Reply With Quote


Old 06-13-2007   #2 (permalink)
Djzzero
Junior Member
 
Join Date: Jun 2007
Posts: 24
Default Re: How to send cookies to the client

Thanks, Ive been wondering how to do the code to save cookies to a client :). Thanks very much!
Djzzero is offline   Reply With Quote

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW TO: Send email using System.Net.Mail shawn .NET 4 05-15-2008 08:20 PM
Does Google Send Checks Anywhere? GuyKels Google 10 06-20-2007 06:47 PM
Tracking Cookies, with MySQL and CGI.pm Ankita Perl 0 08-19-2006 09:43 AM
I have a client on a budget ... rowedf Marketing 2 07-23-2006 02:36 PM


footer left
All times are GMT. The time now is 06:39 PM.

DISCLAIMER: preCharge Risk Management is not responsible for any opinions, advice or comments expressed on the preCharge Community Forums.
preCharge® is a registered trademark of preCharge Risk Management | chargeback protection | Merchant Account Blog

Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC6

Finance | Cheap Electricity | Wordpress Hosts | First Time Home Buyer | Debt Consolidation

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49