Example of using Cookies
This web page contains examples of using Cookies. Most of
this web page content was created by JavaScript functions.
-
Is cookies enabled? - see
the function isCookiesEnabled() in the ex_cookie.js file.
-
To see the contents of the cookie that can be used on a specific web page do
the following:
1) In the URL goto the following: javascript:document.cookie
2) Click the browsers back arrow to return back to the prior page.
-
Cookie Contents in new window - for a new window with the cookie info!
( runs the custom function: fCookieHtmlPage() )
-
Cookie Contents - cookie contents
displayed in the same window.
<a href="javascript:document.cookie">Cookie Contents</a>
-
Alert the Cookie Contents -
cookie contents displayed in an alert popup.
<a href="javascript:alert(document.cookie)">Alert the Cookie Contents</a>
Other resources
Source Files for the example:
-
There are 2 files involved: ex_cookies.htm
& ex_cookies.js
-
View this source, then cut and paste to a file named: ex_cookies.htm
-
Click Here - to download
ex_cookies.js file to see the main JavaScript logic.
The next table is created by the
JavaScript function: fHtmlCookieDemoA().
The next table is created by the
JavaScript function: fListAllCookies().
Display Cookie_03 value.
Development Testing - used for development testing.
Display Current Cookie Information.
(Note: 'myexpire' expires in 10 secs.)