Cookies are a way of storing information about a user on the users computer. Cookies can be used to track a users visits to and path through a web site, store a users choices, and much more.
Welcome to Bucaro TecHelp!

Welcome to Bucaro TecHelp!
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact Advertise on Bucaro TecHelp Advertise Here RSS News Feeds News Feeds

HTML5 Solutions: Essential Techniques for HTML5 Developers

Essential Techniques for HTML5 Developers

HTML5 brings the biggest changes to HTML in years. Web designers now have new techniques, from displaying video and audio natively in HTML, to creating realtime graphics on a web page without a plugin.

This book provides a collection of solutions to all of the most common HTML5 problems. Every solution contains sample code that is production-ready and can be applied to any project.

Click Here

Cookie Power Made Easy

Cookies are a way of storing information about a user on the users computer. Cookies can be used to track a users visits to and path through a web site, store a users choices, and much more. A cookie can not be larger than 4096 bytes, only a maximum of 20 cookies can be stored per domain, and only 300 cookies total can be stored.

Where cookies are stored on the users computer varies with the browser version and the operating system. In some cases all cookies are written to a single file. On Windows 2000 cookies are stored under each users My Documents folder. On Windows 98 cookies are stored under the Windows folder.

All the cookies saved from an individual web page are stored in one file. Each web page has a related cookie file. When a user requests a web page from a server, the browser searches for a related cookie file on the users computer. The cookie file would have been created by previous visits to that web page.

If any cookies are found they are loaded into the page's document.cookie property. If you are familiar with the browser document object model, you would expect the cookie property to contain a collection of cookies. Instead, the cookie property contains a single string of text.

It is easy to store a cookie from your web page. Just use JavaScript to assign values to the document.cookie property as shown below.

document.cookie="cookiename=cookievalue";

The line above shows the minimum requirement to create a cookie. A cookie may contain up to five parts separated by semicolons as shown below.

"name=value; expires=date; path=path; domain=domain; secure"

Because all the cookies related to one web page or one domain are written to a single file, retrieving a cookie is a bit more difficult. For experimenting or debugging you can generate a popup dialog box displaying a list of all the cookies related to a web page by typing the following line into the address text box of your browser.

JavaScript:alert(document.cookie.split(';').join('\n')

To use cookies with your web page you have to be able to extract the specific cookie that you are interested in from the browsers cookie property string. The JavaScript code below will perform that function.

function getCookie(name)
{
 var cookieFound = false;
 var start = 0;
 var end = 0;
 var cookieString = document.cookie;
 var i = 0;

 while(i <= cookieString.length)
 {
  start = i;
  end = start + name.length;
  if(cookieString.substring(start,end) == name)
  {
    cookieFound = true;
    break;
  }
  i++;
 }

 if(cookieFound)
 {
  start = end + 1;
  end = document.cookie.indexOf(";",start);
  if(end < start)
    end = document.cookie.length;
  return document.cookie.substring(start,end);
 }
 return "";
}

frequently we want to store more than a single piece of information for a web page. You could achieve this by setting and retrieving multiple cookies. However, if you have other cookie setting code on your web site, for example advertising banners, you could quickly exceed the 20 cookies per domain maximum. When you exceed the maximum, the browser will delete the oldest cookie and retain the most recent 20.

Web Design Sections

RSS Feed RSS Feed

Google Reader or Homepage
Add to My Yahoo!
Subscribe with Bloglines

Add to My AOL
Add to Technorati Favorites!

Java Script Quick Reference
Java Script Data Types
Java Script Reserved Words
JavaScript Operators
Java Script Arrays
Java Script Character Encoding and Decoding
Comparison Operators
The if/else Structure
The Conditional Operator
The switch/case Structure
The for Loop
The while Loop
The break Statement
The continue Statement
JavaScript Math Object
Java Script Arithmetic Operators
Round a Number
Determine Absolute Value
Determine Minimum and Maximum
Generating Random Numbers
Java Script Trigonometric Methods
Java Script Number Object
Format a Number as Currency
Java Script Strings
Compare Two Strings
Find a Character or a Substring Within a String
Include a Quote Character in a String
Include a Backslash Character in a String
Define Lines in a String
Use Escape to Replace Dangerous Characters
Convert a Number to a String
Convert a String to a Number
The Document Object Model (DOM)
Accessing Web Page Elements
The Location Object
The Screen Object
Access Web Page Elements With getElementById
Interactively Set Webpage Colors
Get Webpage File Date and File Size
Dueling Windows
Cookie Power Made Easy
Web Designer's Reference


[Site User Agreement] [Advertise on This site] [Search This Site] [Contact Form]
Copyright©2001-2011 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268