OLibJ Cookie API Reference

Table Contents
parse API test
Parse Current cookie and save on cookies global variable as associative array. This method is auto execute when include OJ.Cookie class. return: void OJ.Cookie.parse ()
<script type="text/javascript" src="olibj/cookie.js"></script> <script type="text/javascript"> for ( var key in cookies ) document.write (key + ': ' + cookies[key] + '<br>\n'); </script>
get API test
Get current cookie. return: string OJ.Cookie.get (key)
<script type="text/javascript"> var val1 = OJ.Cookie.get ('PHPSESSID'); var val2 = cookies.PHPSESSID; </script>
remove API test
Remove cookie return: void OJ.Cookie.remove (key)
<script type="text/javascript"> OJ.Cookie.remove ('PHPSESSID'); </script>
set API test
Set cookie. Parameters: key : Cookie key value : Cookie value expire : Expire days return: void OJ.Cookie.set (key, value, expire)
<script type="text/javascript"> OJ.Cookie.set ('test1', 'this is value of test1 cookie', 30); </script>
compare API test
Compare cookie with given data. Parameters: key : Cookie key value : comapre data return: bool OJ.Cookie.compare (key, value)
<script type="text/javascript"> var compare = 'asdfbcdsafdsa'; if ( OJ.Cookie.compare ('PHPSESSID', compare) === false ) { alert ('No Match with ' + compare); } if ( cookies.PHPSESSID != compare ) { alert ('No Match with ' + compare); } </script>