|
JavaScript Home
JavaScript TutorialIntroductionHow to Enable JavaScript JavaScript Syntax JavaScript Popup Boxes JavaScript and HTML External JavaScript File JavaScript Operators JavaScript Variables JavaScript Functions JavaScript Events JavaScript If Statements JavaScript Switch Statements JavaScript While Loop JavaScript For Loop JavaScript Try Catch JavaScript Escape Characters JavaScript Void(0) JavaScript Cookies JavaScript Date and Time JavaScript Arrays Two Dimensional Arrays JavaScript innerHTML JavaScript Summary JavaScript ReferenceJavaScript Reserved WordsJavaScript Event Handlers JavaScript Date and Time Functions JavaScript ExamplesList of ExamplesJavaScript Dropdown Menu JavaScript Print JavaScript Alert Box JavaScript Confirm JavaScript Prompt JavaScript Status Bar Messages Image Rollovers Popup Windows JavaScript Redirect Timed JavaScript Redirect JavaScript Refresh Page |
JavaScript CookiesCookies are small text files that sit on your hard disk. Cookies are created when you visit websites that use cookies to store information that they need (or prefer). Websites often use cookies to personalise the user experience - such as remembering your name (assuming you supplied it previously) or remembering the items in your shopping cart from previous visits. Despite the many misconceptions about cookies being malicious, they are quite harmless. Cookies can't give your personal details to other websites, or transmit a virus or anything like that. A cookie can only be read by the server that created it. Websites normally use cookies to make its users' lives easier, not harder. Creating Cookies in JavaScript
Now check your cookies folder to see if the cookie was created. Alternatively, write code to read the cookie. Note: If the cookie wasn't created, check the expiry date - it needs to be a date in the future. You can update this value by using the same code with a different value. If you want to add a second value, simply use a different variable name (for example "myContents2="). Reading Cookies in JavaScript
You simply reference the cookie using
Deleting Cookies in JavaScriptTo delete a cookie, you can use the same code you used to create it but this time, set the expiry date in the past:
Once you are comfortable with JavaScript and cookies, you can do things like use the |
Need Website Content?
Get unique, quality digital content for your website.
|