How to create a cookie?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

How to create a cookie?

Rating:

The cookie is a property of the document object. It is used for sending and receiving data between the Web browser and a Web server.

Cookies can be created in JavaScript by using the following syntax:

document.cookie="cookiename=cookiedata
[; expires=timeinGMTstring]
[; path=pathname]
[; domain=domainname]
[; secure]"


In the above syntax, cookiename is the name with which the cookie will be saved on the client computer.

The cookiedata is the data that is sent through the cookie.

The expires attribute is set to delete the cookie file after a certain date. The date should be converted to GMT string.

The path attribute is used to set the path of the directory from which the cookie is active.

The domain is used to search the domain to which the cookie is to be sent.

If the secure attribute is set, the cookies can only be accessible on the sites with secure connections.


Rating:



Other articles

Click here to Article home

MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW Certification: CIW foundation, CIW Professional, Site Designer    Photoshop ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.
 
HACKER SAFE certified sites prevent over 99.9% of hacker crime.