Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function split() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 101

Deprecated: Function eregi_replace() is deprecated in /home3/vvaswani/sql.php on line 301

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home3/vvaswani/public_html/community/columns/trog/article.php on line 107

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home3/vvaswani/public_html/community/columns/trog/article.php on line 109

Deprecated: Function ereg_replace() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 124

Deprecated: Function ereg_replace() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 125

Deprecated: Function split() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 127

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174
The Melonfire Community - Trog
Logo         Community
  Trog
Services
The Company
Community
Columns
Your Account
Contact Us
 
 
The JSP Files (part 6): State Of Grace
Learn how to "maintain state" on a JSP-based Web site with the Cookie and Session objects.

| A Few Ground Rules |

Since cookies are used to record information about your activities on a particular site, they can only be read by the site that created them. For example, Yahoo and Deja.com store your username in a cookie on your hard drive and use this information to automatically fill in log-in forms the next time you visit their Web sites. It's kinda like going to a chic restaurant, and having the maitre'd call you by name (something which hasn't happened to us of late!)

Before getting into the nitty-gritty of cookie technology, a few ground rules are in order:

1. A single domain cannot set more than twenty cookies. A single cookie cannot exceed 4 KB in size. The maximum number of cookies that may be set is 300.

2. The most common method of transmitting a cookie to a client is via the "Set-Cookie" HTTP header.

3. A cookie usually possesses five types of attributes.

The first of these is a NAME=VALUE pair, used to store information such as a username, email address or credit-card number. The NAME is a string used to identify the cookie, while the VALUE is the data to be stored in the cookie. For example,

clarkkent=superman

The EXPIRES attribute defines the date on which the cookie is automatically removed from the system. The date must be in the format "weekday, dd-mon-yy  hh:mm:ss GMT". For example,

expires="Sun, 31-Dec-2030 17:51:06 GMT"

Cookies without a specifically defined expiry date remain active for so long as the browser remains open, and are destroyed once the browser is closed. You can delete an existing cookie be setting this attribute to a date in the past.

The PATH attribute is used to set the top-level directory on the Web server from which cookies can be accessed. In most cases, this is set to

path=/

to ensure that the cookie can be accessed by each and every document on the server.

The DOMAIN attribute is used to specify the domain which the cookie is linked to, and the SECURE attribute indicates that a cookie should only be set if there exists a secure protocol between the browser and the server.

4. Of all the five attributes, the first is the only one that is not optional.

5. Every good browser offers users the option to disable cookies. If a user decides to exercise his or her right to do so, your cookies will not be stored, and any attempt to access them will fail. Users who do this are usually career criminals or tax evaders.


How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!


previous page more like this  print this article  next page
 
Search...
 
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
more...
 
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
more...
 
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
more...
 
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
more...
 
In cut!...
American Chai
The Core
Possession
more...
 
Find out how you can use this article on your own Web site!


Copyright © 1998-
Strict Standards: mktime(): You should be using the time() function instead in /home3/vvaswani/public_html/community/columns/trog/article.php on line 731
2018 Melonfire. All rights reserved
Terms and Conditions | Feedback