JavaScript and Cookies : Cookie « Development « JavaScript Tutorial

JavaScript Tutorial
1. Language Basics
2. Operators
3. Statement
4. Development
5. Number Data Type
6. String
7. Function
8. Global
9. Math
10. Form
11. Array
12. Date
13. Dialogs
14. Document
15. Event
16. Location
17. Navigator
18. Screen
19. Window
20. History
21. HTML Tags
22. Style
23. DOM Node
24. Drag Drop
25. Object Oriented
26. Regular Expressions
27. XML
28. GUI Components
29. Dojo toolkit
30. jQuery
31. Animation
32. MS JScript
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
JavaScript Tutorial » Development » Cookie 
4. 4. 1. JavaScript and Cookies

A cookie is a small bit of information stored in a text file on the user's computer by a browser.

The cookie object is part of the Document object.

Cookies can be created, set, and modified by setting the appropriate values of the cookie property.

A cookie has four name attributes: expires, path, domain, and secure.

By default, a cookie lasts only during the current browsing session.

For a cookie to last beyond the current browsing session, the expires attribute must be set.

The value of expires attribute can be set to any valid date string.

The path attribute specifies the domain associated with the cookie.

The level of association begins at the specified path and goes down into any subfolders.

So for example, suppose http://www.java2java.com/examples/cookie.html was setting a cookie and wanted the cookie to be shared across Web pages on the java2s.com domain.

To do this, the cookie path attribute needs to be set to "/".

This allows the cookie to be accessed from any page on the www.java2java.com Web server.

If the path was set to "/examples", the cookie would only be valid to pages in the examples folder and its subfolders.

If the secure attribute is specified, the cookie will be only be transmitted over a secure channel (HTTPS).

If secure is not specified, the cookie can be transmitted over any communications channel.

4. 4. Cookie
4. 4. 1. JavaScript and Cookies
4. 4. 2. Reading Cookies
4. 4. 3. Writing Cookies
4. 4. 4. Create a cookie and read it back
4. 4. 5. Make cookie using Javascript
4. 4. 6. Delete all cookies
4. 4. 7. Read cookie value
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.