JavaScript
  Home arrow JavaScript arrow Using Cookies With JavaScript
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
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? 
Google.com  
JAVASCRIPT

Using Cookies With JavaScript
By: Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 147
    2004-04-26


    Table of Contents:
  • Using Cookies With JavaScript
  • Caveat Emptor
  • What's In A Name?
  • Cookie-Cutter Code
  • Running The Numbers
  • Speaking Native
  • Dinner Time

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    Using Cookies With JavaScript
    ( Page 1 of 7 )

    In this article, find out how to store and retrieve persistent data with cookies, small files that allow you to do big things. This article explains the basics of cookies, demonstrates reading and writing them in JavaScript, and illustrates their use in a real-world application.

    Big Brother is Watching

    In your travels across the Web, I'm sure you've experienced Web sites that seem to know you only too well, displaying your name and email address when you visit them and (in some cases) even remembering the pages you visited the last time you were there. Before you allow your paranoia full rein, though, let me tell you that you probably provided the information yourself to the site in some previous visit, and what you see when you return is merely the results of your own actions, reprocessed for a better visitor experience.

    So how do they do it? Well, most of these sites save personal information, such as your name and email address, in files on your hard drive, and read these files every time you re-visit the site. These files are known as cookies, and they're a simple and easy way to add personalization features to your site. Cookies can also be used to record information about your activities on a particular site; however, they can only be read by the site that created them.

    If you have a Web site which caters to a large number of visitors, think of how beneficial similar technology could be to you. You could recognize frequent visitors and greet them by name, "remember" the pages they browsed on their last visit and pop up recommendations for similar content, personalize their experience so that they see your Web site in their favourite colours or layout...the possibilities are endless. And over the course of this article, I'm going to get you started down this particular road, by showing you how to read and write cookies using JavaScript, my favourite language for client-side scripting.



     
     
    >>> More JavaScript Articles          >>> More By Nariman K, (c) Melonfire
     

       

    JAVASCRIPT ARTICLES

    - Introduction to JavaScript
    - Adding Elements to a Tree with TreeView jQue...
    - Using the Persist Argument in a TreeView jQu...
    - Using Unique and Toggle in a TreeView jQuery...
    - Using Event Delegation for Mouseover Events ...
    - Using the Animate Option in a Treeview jQuer...
    - Using HTML Lists with Event Delegation in Ja...
    - Opened and Closed Branches on a TreeView jQu...
    - Mouseover Events and Event Delegation in Jav...
    - Creating a TreeView JQuery Hierarchical Navi...
    - Event Delegation in JavaScript
    - A Look at the New YUI Carousel Control
    - Working with Draggable Elements and Transpar...
    - Displaying Pinned Handles with Resizable Con...
    - Building Resizable Containers with the Ext J...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek