YUI recommends YUI3.
YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.
This documentation is no longer maintained.
This example shows basic usage of the YUI Cookie utility. The example checks the value of a cookie and then sets it to a new value.
Keep an eye on the Logger console at right to view the log messages associated with this example.
This example begins by getting the value of a cookie named "example". If this is the first time you've run
the example, the value should be null
:
This value is output into the Logger. Next, the cooke is set to a random value:
When you reload the page, the value of the cookie should be the one that was just set.
Note: this example uses session cookies, so the value will be lost if you close the browser.
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.
Copyright © 2013 Yahoo! Inc. All rights reserved.