ASP.NET
  Home arrow ASP.NET arrow Page 10 - Databases and Cookies
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Databases and Cookies
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 7
    2004-11-03

    Table of Contents:
  • Databases and Cookies
  • Key Points About Cookies
  • Looking at your cookies
  • Examples of Using Cookies
  • Try It Out – Setting and Reading a Cookie with ASP Alone
  • How it Works – Setting and Reading a Cookie with ASP Alone
  • Using Cookies with ADO and a Database
  • Try It Out – Setting a Cookie Using ASP–ADO
  • How it Works – Setting a Cookie Using ASP–ADO
  • Resetting a Cookie
  • Try It Out – Resetting a Cookie
  • How It Works – Resetting a Cookie
  • Summary

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Databases and Cookies - Resetting a Cookie


    (Page 10 of 13 )

    There are two cases for setting a cookie. The first is that no cookie existed because the person was never registered, that is, they have no record in the database. But a frequent second type of case is that a person has a record in the People table but they have lost their cookie. This could be for many reasons, as discussed earlier in the chapter. In this case we want to reset a cookie.

    In this second case, it is nice to give people a way to reset their cookie quickly and easily, without reentering all of their information in the People table. In fact, we specifically want to avoid the latter since re-entering their data could easily lead to duplicate records for people.

    In other words, we don't want to enter this person as a new record in the database like we would when first setting a cookie; rather we want to identify their existing record in the database and use that to set a cookie.

    The solution to the second problem is to build a page that gives cookie-less visitors several options. Firstly, they could pick their name out of a drop-down list of names already in your People table. You can also give the visitor the option of visiting without a cookie. The third is that they can register, which will respond by both adding them as a record in the People table and setting a cookie on their hard drive. A fourth option is to ask the visitor to sign in at the beginning of each visit. The sign-in could be by name, member ID or a field like Email address. Although tedious, some visitors prefer signing in to setting a cookie.

    You must also weigh up which options you want to offer in view of your security. In an Internet site, you would not want to reveal the names of all your visitors in a drop-down box. Likewise, with more than a few score members, you could not offer a drop-down list of names, and would have to gather the name by a text field and do a match with the database. But let us cover an example here for a departmental intranet with a few dozen users.

    There are four pages or parts of pages that are needed for this process:

    • First, our cookie-using home page must be modified to detect a missing cookie.

    • Second, we must create a form for resetting a cookie, which offers a list of members.

    • Third, we need a page that will set a cookie based on the selection in the above page.

    • Last, when we reset a cookie, we will provide to the user a confirmation page.

    This is from Beginning ASP Databases by Kauffman, Spencer, and Willis (Apress, ISBN 1590592492). Check it out at your favorite bookstore today.

    Buy this book now.

    More ASP.NET Articles
    More By Apress Publishing


       · i really need help adding the updated information to my database
     

    ASP.NET ARTICLES

    - Developing a Mini ASP.NET AJAX Server Centri...
    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT